#pragma GCC optimize("O3")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <random>
#include <string>

using namespace std;
#define int long long
using ll = long long;
using ld = long double;

#define dbg(x) cerr << #x << ": " << x << '\n'

const int LG = 20, INF = 1e18;
vector<pair<int, int>> tree;
int n, m, t;

void build(vector<int>& a, int v = 1, int l = 0, int r = n) {
	if (r - l <= 1) {
		tree[v].first = a[l];
		tree[v].second = l;
		return;
	}
	int mid = (l + r) / 2;
	build(a, v * 2, l, mid);
	build(a, v * 2 + 1, mid, r);
	tree[v] = min(tree[v * 2], tree[v * 2 + 1]);
}

pair<int, int> get(int ql, int qr, int v = 1, int l = 0, int r = n) {
	if (ql <= l && r <= qr) {
		return tree[v];
	}
	if (l >= qr || r <= ql) {
		return { INF, INF };
	}
	int mid = (l + r) / 2;
	pair<int, int> left = get(ql, qr, v * 2, l, mid);
	pair<int, int> right = get(ql, qr, v * 2 + 1, mid, r);
	return min(left, right);
}

int solve(vector<int> a, vector<int> bsh) {
	tree = vector<pair<int, int>>(n * 4, {INF, INF});
	build(a);
	vector<int> pref(n + 1);
	for (int i = 0; i < n; i++) pref[i + 1] = pref[i] + a[i];
	int ans = 0;
	for (int iter = 0; iter < m; iter++) {
		int b = bsh[iter];
		int l = b, r = n;
		while (r - l > 2) {
			int m1 = l + (r - l) / 3;
			int m2 = r - (r - l) / 3;
			pair<int, int> p1 = get(b, m1 + 1);
			pair<int, int> p2 = get(b, m2 + 1);
			m1 = p1.second;
			m2 = p2.second;
			if (pref[m1] - pref[b] > t) {
				r = m1;
			}
			else if (pref[m2] - pref[b] > t) {
				r = m2;
			}
			else {
				int left1 = t - (pref[m1] - pref[b]);
				int left2 = t - (pref[m2] - pref[b]);
				if (m1 - b + left1 / p1.first < m2 - b + left2 / p2.first) {
					l = m1;
				}
				else {
					r = m2;
				}
			}
		}
		for (int resm = max(b, l - 20); resm < min(l + 20, n); resm++) {
			int left = t - (pref[resm] - pref[b]);
			pair<int, int> p = get(b, resm + 1);
			ans = max(ans, resm - b + left / p.first);
		}
	}
	return ans;
}

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	cin >> n >> m >> t;
	vector<int> a(n), b(m);
	for (int i = 0; i < n; i++) cin >> a[i];

	for (int i = 0; i < m; i++) {
		cin >> b[i];
		b[i]--;
	}
	int ans = solve(a, b);
	reverse(a.begin(), a.end());
	for (int i = 0; i < m; i++) b[i] = n - b[i] - 1;
	ans = max(ans, solve(a, b));
	cout << ans;
}
