#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;
vector<vector<int>> sparse;

int get(int l, int r) {
	int st = 0;
	while ((1ll << st) < (r - l + 1) / 2) st++;
	return min(sparse[l][st], sparse[r - (1ll << st)][st]);
}
int n, m, t;
int solve(vector<int> a, vector<int> bsh) {
	sparse = vector<vector<int>>(n, vector<int>(LG));
	for (int i = 0; i < n; i++) sparse[i][0] = a[i];
	for (int st = 1; st < LG; st++) {
		for (int i = 0; i < n; i++) {
			sparse[i][st] = min(sparse[i][st - 1], sparse[max(0ll, i - (1ll << st))][st - 1]);
		}
	}
	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;
			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 / get(b, m1 + 1) < m2 - b + left2 / get(b, m2 + 1)) {
					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]);
			ans = max(ans, resm - b + left / get(b, resm + 1));
		}
	}
	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;
}
