//#pragma GCC optimize("O3, unroll-loops, no-stack-protector")
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#define int long long

using namespace std;

const int INF = 2e15;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, m, t;
	cin >> n >> m >> t;
	vector <int> arr(n), pref(n + 1), brr(m);
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		pref[i + 1] = pref[i] + arr[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> brr[i];
		brr[i]--;
	}
	vector <int> cnt(n);
	for (int i = 0; i < n; i++) {
		int l = -1, r = i;
		while (l + 1 < r) {
			int mid = (l + r) / 2;
			if (pref[i + 1] - pref[mid] <= t) {
				r = mid;
			}
			else {
				l = mid;
			}
		}
		cnt[i] = (t - (pref[i + 1] - pref[r])) / arr[r] + i - r + 1;
	}
	int ans = 0;
	for (auto el : brr) {
		ans = max(ans, cnt[el]);
	}
	cout << ans << '\n';
}
