#ifdef _DEBUG
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cassert>
#include <random>
#include <ctime>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define int int64_t

mt19937 rng(time(nullptr));

void solve() {
	int n, m, t;
	cin >> n >> m >> t;
	vector<int> a(n), b(m);
	for (int& i : a) cin >> i;
	for (int& i : b) cin >> i;
	for (int& i : b) --i;
	sort(b.begin(), b.end());
	vector<int> pref_sum(n + 1, 0);
	for (int i = 1; i <= n; ++i) pref_sum[i] = pref_sum[i - 1] + a[i - 1];
	int ans = 0;

	auto cnt = [&](int start, int finish) -> int {
		// r, r - 1, ..., l + 1
		// 2 3 5 1 [4, 2] => 1 + 5 = 6
		// 0 2 5 10 11
		// pref[r + 1] - pref[l + 1]
		int cur_time = 0;
		int cntt = 0;
		if (start <= finish) {
			for (int i = start; i < finish; ++i) {
				if (cur_time + a[i] <= t) {
					++cntt;
				}
				cur_time += a[i];
			}
			return cntt + max<int>(0, t - cur_time) / a[finish];
		}
		else {
			for (int i = start; i > finish; --i) {
				if (cur_time + a[i] <= t) {
					++cntt;
				}
				cur_time += a[i];
			}
			return cntt + max<int>(0, t - cur_time) / a[finish];
		}
	};

	for (int i = 0; i < n; ++i) {
		auto it = lower_bound(b.begin(), b.end(), i);
		if (it != b.begin()) {
			--it;
			ans = max(ans, cnt(*it, i));
			++it;
		}
		if (it != b.end()) {
			ans = max(ans, cnt(*it, i));
			if (it != (--b.end())) {
				++it;
				ans = max(ans, cnt(*it, i));
			}
		}
		it = upper_bound(b.begin(), b.end(), i);
		if (it != b.end()) {
			ans = max(ans, cnt(*it, i));
		}
		//cout << ans << endl;
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int test = 1;
	//cin >> test;

	while (test--) {
		solve();
	}

	return 0;
}
