#include <bits/stdc++.h>

#define int long long
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using namespace std;

void solve_case() {
    int n, m, T; cin >> n >> m >> T;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> pref(n + 1);
    for (int i = 0; i < n; i++) {
        pref[i + 1] = pref[i] + a[i];
    }
    vector<int> b(m);
    for (int i = 0; i < m; i++) {
        cin >> b[i];
        b[i]--;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        auto it = lower_bound(all(b), i);
        if (it != b.end()) {
            int r = *it;
            int sum = pref[r + 1] - pref[i + 1];
            int t = T - sum;
            if (t >= 0) {
                ans = max(ans, (r - i) + t / a[i]);
            }
        }
        if (it != b.begin()) {
            int l = *prev(it);
            int sum = pref[i] - pref[l];
            int t = T - sum;
            if (t >= 0) {
                ans = max(ans, (i - l) + t / a[i]);
            }
        }
    }
    cout << ans << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve_case();
    }
}