#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>

using namespace std;

#define ll long long 
#define vc vector
#define str string
#define sz(a) (a).size()
#define its(a) (a).begin(), (a).end()
#define itsr(a) (a).rbegin(), (a).rend()
#define scan(a) for (auto &_i:(a)) cin >> _i;

void solve() {
	ll n, m, T; cin >> n >> m >> T;
	/*vc<ll> a(n);
	for (int i = 0;i < n;++i) a[i] = rand() % 1000 + 1;*/
	vc<ll> a(n); scan(a);
	vc<ll> b(m); scan(b);

	vc<ll> lessL(n, -1);
	vc<ll> st;
	for (int i = 0;i < n;++i) {
		while (sz(st) and a[st.back()] > a[i]) {
			st.pop_back();
		}
		if (sz(st)) lessL[i] = st.back();
		st.push_back(i);
	}
	vc<ll> lessR(n, n);
	st.clear();
	for (int i = 0;i < n;++i) {
		while (sz(st) and a[st.back()] >= a[i]) {
			lessR[st.back()] = i;
			st.pop_back();
		}
		st.push_back(i);
	}
	vc<ll> ansL(n), ansR(n);
	for (int i = 0;i < n;++i) {
		ll cur = 0;
		for (int j = i;j < lessR[i];++j) {
			cur += a[j];
			if (cur > T) break;
			ansL[j] = max(ansL[j], j - i + 1 + (T - cur) / a[i]);
		}
		cur = 0;
		for (int j = i;j > lessL[i];--j) {
			cur += a[j];
			if (cur > T) break;
			ansR[j] = max(ansR[j], i-j + 1 + (T - cur) / a[i]);
		}
	}
	ll ans = 0;
	for (auto i : b) ans = max({ ans, ansL[i - 1], ansR[i - 1] });
	cout << ans << '\n';
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll _t = 1;
	//cin >> _t;
	while (_t--)
		solve();
}
