// #pragma GCC optimize("Ofast,fast-math,unroll-loops,no-stack-protector,inline")
#include <bits/stdc++.h>

using namespace std;

#define int long long

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    freopen("input.txt", "r", stdin);
    int n, m, t;
    cin >> n >> m >> t;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    vector<int> pr(n + 1);
    for (int i = 1; i < n + 1; i++) {
        pr[i] = arr[i - 1] + pr[i - 1];
    }
    vector<int> arr1(m);
    for (int i = 0; i < m; i++) {
        cin >> arr1[i];
        arr1[i]--;
    }
    int ind = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (ind < m - 1 && arr1[ind + 1] <= i) {
            ind++;
        }
        int cur = 0;
        int cur_ind = arr1[ind];
        int cur_t = pr[i] - pr[cur_ind];
        if (cur_t < t) {
            ans = max(ans, i - cur_ind + (t - cur_t) / arr[i]);
        }
        if (ind < m - 1) {
            cur_ind = arr1[ind + 1];
            cur_t = pr[cur_ind + 1] - pr[i + 1];
            if (cur_t < t) {
                ans = max(ans, cur_ind = i + (t - cur_t) / arr[i]);
            }
        }
    }
    cout << ans << endl;
}