#include <bits/stdc++.h>

using namespace std;
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef long long ll;

void solve();

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int tt = 1; //cin >> tt;
    while (tt--) {
        solve();
        cout << "\n";
    }
}

void solve() {
    int n, m, T; cin >> n >> m >> T;
    vector<ll> a(n + 1), pref(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }

    vector<int> b(m);
    for (int i = 0; i < m; i++) cin >> b[i];
    sort(all(b));

    map<ll, int> last;
    ll mx = 0;
    for (int i = 0; i < m; i++) {
        int prev = 1;
        if (i > 0) prev = b[i - 1] + 1;
        for (int j = prev; j <= b[i]; j++) {
            if (a[j] <= T)
                last[a[j]] = j;
        }
        for (auto [x, j] : last) {
            ll ans = 0;
            if (pref[b[i]] - pref[j - 1] <= T) {
                ans = b[i] - j + 1;
                ans += (T - (pref[b[i]] - pref[j - 1])) / x;
            }
            mx = max(mx, ans);
        }
    }

    last.clear();
    for (int i = m - 1; i >= 0; i--) {
        int prev = n;
        if (i + 1 < m) prev = b[i + 1] - 1;
        for (int j = prev; j >= b[i]; j--) {
            if (a[j] <= T)
                last[a[j]] = j;
        }
        for (auto [x, j] : last) {
            ll ans = 0;
            if (pref[j] - pref[b[i] - 1] <= T) {
                ans = j - b[i] + 1;
                ans += (T - (pref[j] - pref[b[i] - 1])) / x;
            }
            mx = max(mx, ans);
        }
    }

    cout << mx;
}
