#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define str string
#define pb push_back
#define ins insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pii pair<int, int>
#define ff first
#define ss second
#define ld long double
#define sz(a) (int)a.size()
#define int ll

mt19937 rnd(1488);

void solve(){
    int n, m, t;
    cin >> n >> m >> t;
    vector<int> c(n);
    for (int i = 0; i < n; i++){
        cin >> c[i];
    }
    vector<int> c2(m);
    for (int i = 0; i < m; i++){
        cin >> c2[i];
        --c2[i];
    }
    int j = -1;
    vector<int> l(n);
    vector<int> r(n);
    for (int i = 0; i < n; i++){
        while (j + 1 < m && c2[j + 1] <= i){
            ++j;
        }
        l[i] = j;
        r[i] = j + 1;
    }
    vector<int> pr = {0};
    for (auto i:c){
        pr.pb(pr.back() + i);
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        if (l[i] != -1){
            l[i] = c2[l[i]];
            if (pr[i] - pr[l[i]] <= t){
                int t2 = t - (pr[i] - pr[l[i]]);
                ans = max(ans, i - l[i] + t2 / c[i]);
            }
        }
        if (r[i] != m){
            r[i] = c2[r[i]];
            if (pr[r[i] + 1] - pr[i + 1] <= t){
                int t2 = t - (pr[r[i] + 1] - pr[i + 1]);
                ans = max(ans, r[i] - i + t2 / c[i]);
            }
        }
    }
    cout << ans << "\n";
}

int32_t main(){
    cin.tie(0)->ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif // LOCAL
    int _ = 1;
    //cin >> _;
    while (_--){
        solve();
    }
}
