#include <bits/stdc++.h>

using namespace std;

int n, m, t;

int getl(int ind, vector<int>& a) {
    int ans = 0;
    int cur = 0;
    for (int i = ind; i >= 0; i--) {
        if (cur >= t) break;
        ans = max(ans, ind - i + (t - cur) / a[i]);
        cur += a[i];
    }
    if (last <= lastt && !f) {
        last = lastt;
        continue;
    }
    if (last > lastt && !f) {
        f = 1;
    }
    if (last >= lastt && f) {
        last = lastt;
        continue;
    }
    exit(1);
    return ans;
}

int getr(int ind, vector<int>& a) {
    int ans = 0;
    int cur = 0;
    int last = 0, lastt = 0, f = 0;
    for (int i = ind; i < n; i++) {
        if (cur >= t) break;
        //cout << i - ind + (t - cur) / a[i] << ' ';
        ans = max(ans, i - ind + (t - cur) / a[i]);
        cur += a[i];
        if (last <= lastt && !f) {
            last = lastt;
            continue;
        }
        if (last > lastt && !f) {
            f = 1;
        }
        if (last >= lastt && f) {
            last = lastt;
            continue;
        }
        exit(1);
    }
    return ans;
}

void solve() {
    cin >> n >> m >> t;
    vector<int> a(n), b(m);
    for (auto& i : a) cin >> i;
    for (auto& i : b) cin >> i;
    for (auto& i : b) i--;
    int ans = 0;
    for (int it = 0; it < m; it++) {
        //cout << getl(b[it], a) << ' ' << getr(b[it], a) << '\n';
        ans = max(getl(b[it], a), ans);
        ans = max(getr(b[it], a), ans);
        //cout <<'\n';
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}
