#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), B(m);
    for (ll i = 0; i < n; i++) {
        cin >> A[i];
    }
    for (ll i = 0; i < m; i++) {
        cin >> B[i];
    }
    vector<ll> pref(n + 1);
    for (ll i = 0; i < n; i++) {
        pref[i + 1] = pref[i] + A[i];
    }
    ll mx = 0;
    for (ll i = 0; i < m; i++) {
        ll l = -1, r = B[i];
        while (r - l > 1) {
            ll mid = (l + r) / 2;
            if (pref[B[i]] - pref[mid] > T) {
                l = mid;
            } else {
                r = mid;
            }
        }
        //cout << i << ' ' << r << '\n';
        mx = max(mx, (pref[B[i]] - pref[r]) / A[i] + (B[i] - r));
    }
    cout << mx << '\n';
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t = 1;
    //cin >> t;
    for (ll i = 0; i < t; i++) {
        solve();
    }
    return 0;
}
