#include <bits/stdc++.h>
using namespace std;
#define int long long

main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m, T;
    cin >> n >> m >> T;
    vector < int > a(n), b(m);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];
    for (int i = 0; i < m; i++) b[i]--;
    vector < int > pref(n + 1);
    for (int i = 0; i < n; i++) pref[i + 1] = pref[i] + a[i];
    int ans = 0;
    for (int i = 0; i < n; i++) {
        auto it = upper_bound(begin(b), end(b), i);
        int l = -1, r = -1;
        if (it != b.end()) r = *it;
        if (it != b.begin()) l = *prev(it);
        if (r != -1) {
            int dt = pref[r + 1] - pref[i + 1];
            if (dt <= T) {
                int cur = r - i;
                int tm = T - dt;
                cur += tm / a[i];
                ans = max(ans, cur);
            }
        }
        if (l != -1) {
            int dt = pref[i] - pref[l];
            if (dt <= T) {
                int cur = i - l;
                int tm = T - dt;
                cur += tm / a[i];
                ans = max(ans, cur);
            }
        }
    }
    cout << ans;
}
