#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
// #pragma GCC optimize("03")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("avx,avx2,bmi2,fma")


signed main() {
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n, m, T;
    cin >> n >> m >> T;
    vector<int> a(n), b(m), pref(n + 1);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        pref[i + 1] = pref[i] + a[i];
    }
    for (auto& it : b) {
        cin >> it;
        it--;
    }

    int ans = 0, ind = 0;
    for (int i = 0; i < n; ++i) {
        // cout << i << ' ' << b[ind] << endl;
        if (b[ind] <= i && (pref[i] - pref[b[ind]]) <= T) {
            // cout << "F1 ";
            // cout << (i - b[ind]) << ' ' << (T - (pref[i] - pref[b[ind]])) / a[i] << ' ' << (pref[i] - pref[b[ind]]) << endl;
            ans = max(ans, (i - b[ind]) +  (T - (pref[i] - pref[b[ind]])) / a[i]);
        }
        if (ind + 1 < m && b[ind + 1] >= i && (pref[b[ind + 1] + 1] - pref[i + 1]) <= T) {
            // cout << "F2 ";
            // cout << (b[ind + 1] - i) << ' ' << (T - (pref[b[ind + 1] + 1] - pref[i + 1])) / a[i] << endl;
            ans = max(ans, (b[ind + 1] - i) + (T - (pref[b[ind + 1] + 1] - pref[i + 1])) / a[i]);
        }
        if (ind + 1 < m && b[ind + 1] == i) {
            ind++;
        }
        if (ind + 1 < m && b[ind + 1] >= i && (pref[b[ind + 1] + 1] - pref[i + 1]) <= T) {
            // cout << "F2 ";
            // cout << (b[ind + 1] - i) << ' ' << (T - (pref[b[ind + 1] + 1] - pref[i + 1])) / a[i] << endl;
            ans = max(ans, (b[ind + 1] - i) + (T - (pref[b[ind + 1] + 1] - pref[i + 1])) / a[i]);
        }
    }

    cout << ans << endl;
}

/*
5 3 10
4 5 2 7 1
1 2 4

4


4 2 11
4 5 7 10
2 3

2


6 1 10
3 3 4 5 5 6
2

*/