#include<bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,sse3,sse4,bmi,bmi2,popcnt,lzcnt,tune=native")
#define int long long
using namespace std;
main() {
    int n, m, t;
    cin >> n >> m >> t;
    int a[n + 1];
    int pref[n + 1] = {};
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    int ans = 0;
    for (int i = 1; i <= m; i++) {
        int x;
        cin >> x;
        if (i <= 500 || (m - i + 1) <= 500) {
            for (int y = x; y >= 1; y--) {
                if (pref[x] - pref[y] <= t) {
                    ans = max(ans, x - y + (t - (pref[x] - pref[y])) / a[y]);
                } else {
                    break;
                }
            }
            for (int y = x; y <= n; y++) {
                if (pref[y - 1] - pref[x - 1] <= t) {
                    ans = max(ans, y - x + (t - (pref[y - 1] - pref[x - 1])) / a[y]);
                } else {
                    break;
                }
            }
        } else {
            for (int y = 1; y <= min(x, 500LL); y++) {
                if (pref[x] - pref[y] <= t) {
                    ans = max(ans, x - y + (t - (pref[x] - pref[y])) / a[y]);
                }
            }
            for (int y = x; y <= min(n, x + 500LL); y++) {
                if (pref[y - 1] - pref[x - 1] <= t) {
                    ans = max(ans, y - x + (t - (pref[y - 1] - pref[x - 1])) / a[y]);
                }
            }
            for (int y = max(x - 500, 1LL); y <= x; y++) {
                if (pref[x] - pref[y] <= t) {
                    ans = max(ans, x - y + (t - (pref[x] - pref[y])) / a[y]);
                }
            }
            for (int y = max(n - 500LL, x); y <= n; y++) {
                if (pref[y - 1] - pref[x - 1] <= t) {
                    ans = max(ans, y - x + (t - (pref[y - 1] - pref[x - 1])) / a[y]);
                }
            }
        }
    }
    cout << ans << endl;
}
