#include <bits/stdc++.h>

using ll = long long;
using namespace std;

void solve() {
    ll n, m, t;
    cin >> n >> m >> t;
    vector <ll> a(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector <ll> prev(n + 1, 0);
    for (ll i = 0; i < n; ++i) {
        prev[i + 1] = prev[i] + a[i];
    }
    vector <ll> b(m);
    for (ll i = 0; i < m; ++i) {
        cin >> b[i];
        --b[i];
    }
    ll ans = 0;
    for (ll i = 0; i < n; ++i) {
        auto it = upper_bound(b.begin(), b.end(), i);
        if (it != b.end()) {
            ll ind = *it;
            if (t - (prev[ind + 1] - prev[i + 1]) >= 0) {
                ans = max(ans, ind - i + (t - prev[ind + 1] + prev[i + 1]) / a[i]);
            }
        }
        if (it != b.begin()) {
            --it;
            ll ind = *it;
            if (t - (prev[i] - prev[ind]) >= 0) {
                ans = max(ans, i - ind + (t - prev[i] + prev[ind]) / a[i]);
            }
        }
    }
    cout << ans << '\n';
}
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}
