#include <bits/stdc++.h>
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define endl '\n'
typedef long long ll;
using namespace std;

const int INF = 1e9 + 5;
const int N = 3e5 + 5;
ll a[N], b[N], pref[N];
ll ans[N];

void solve() {
    int n, m;
    ll t;
    cin >> n >> m >> t;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }

    for (int i = 1; i <= m; i++) cin >> b[i];

    ll ans = 0;

    int l = 1;
    for (int i = 1; i <= n; i++) {
        while (l < m && b[l + 1] <= i) l++;

        if (b[l] <= i) {
            int j = b[l];
            ll sum = pref[i - 1] - pref[j - 1];
            if (sum <= t) {
                ans = max(ans, i - j + (t - sum) / a[i]);
            }
        }
    }

    l = m;
    for (int i = n; i > 0; i--) {
        while (l > 1 && b[l - 1] >= i) l--;

        if (b[l] >= i) {
            int j = b[l];
            ll sum = pref[j] - pref[i];
            if (sum <= t) {
                ans = max(ans, j - i + (t - sum) / a[i]);
            }
        }
    }

    cout << ans << endl;
}

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

    solve();
}
