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

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m, T;
    cin >> n >> m >> T;
    vector<int> A(n + 1), pref(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> A[i];
        pref[i] = pref[i - 1] + A[i];
    }
    vector<int> B(m);
    for (int i = 0; i < m; i++) {
        cin >> B[i];
    }
    int res = 0;
    for (int i = 1; i <= n; i++) {
        auto it = lower_bound(B.begin(), B.end(), i);
        if (it != B.begin()) {
            int pos = *prev(it);
            if (pref[i] - pref[pos - 1] <= T) {
                int x = T - (pref[i] - pref[pos - 1]);
                res = max(res, i - pos + 1 + x / A[i]);
            }
        }
        if (it != B.end()) {
            int pos = *it;
            if (pref[pos] - pref[i - 1] <= T) {
                int x = T - (pref[pos] - pref[i - 1]);
                res = max(res, i - pos + 1 + x / A[i]);
            }
        }
    }
    cout << res;
    return 0;
}