#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll infll = 1e18;

template<typename T>
istream& operator>>(istream& is, vector<T>& a) {
	for (auto& i : a) {
		is >> i;
	}
	return is;
}

int32_t main() {
#ifdef LOCAL
	assert(freopen("C:\\Users\\User\\input.txt", "r", stdin));
#else
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
#endif
	int n, m, t;
	cin >> n >> m >> t;
	vector<int> a(n), b(m);
	cin >> a >> b;
	for (auto& i : b) {
		--i;
	}
	assert(n == m);
	vector<ll> pref(n + 1);
	for (int i = 1; i <= n; ++i) {
		pref[i] = pref[i - 1] + a[i - 1];
	}
	ll ans = 0;
	int j = 0;
	{
		for (int k = b[0]; k < n; ++k) {
			ll cur = pref[k] - pref[b[0]];
			if (cur <= t) {
				if (ans <= k - b[0] + (t - cur) / a[k]) {
					ans = k - b[0] + (t - cur) / a[k];
					j = k;
				}
			}
		}
	}
	for (int i = 1; i < m; ++i) {
		while (j < n && pref[j] - pref[b[i]] <= t) {
			ans = max(ans, j - b[i] + (t - (pref[j] - pref[b[i]])) / a[j]);
			++j;
		}
	}
	j = n;
	{
		for (int k = b[m - 1]; k >= 0; --k) {
			ll cur = pref[b[m - 1] + 1] - pref[k + 1];
			if (cur <= t) {
				if (ans <= b[m - 1] - k + (t - cur) / a[k]) {
					ans = b[m - 1] - k + (t - cur) / a[k];
					j = k;
				}
			}
		}
	}
	for (int i = m - 2; i >= 0; --i) {
		while (j >= 0 && pref[b[i] + 1] - pref[j + 1] <= t) {
			ans = max(ans, b[i] - j + (t - (pref[b[i] + 1] - pref[j + 1])) / a[j]);
			--j;
		}
	}
	cout << ans << "\n";
	return 0;
}