#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define int ll

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
    int n, m, t; cin >> n >> m >> t;
    vector<int> a(n);
    for (int &u : a) cin >> u;

    vector<int> b(m);
    for (int i = 0; i < m; i++) cin >> b[i];
    vector<int> pref(n + 1);
    for (int i = 1; i <= n; i++) pref[i] = pref[i - 1] + a[i - 1];
    vector<int> xd(n);
    for (int u:b) xd[u - 1] = 1;

    int best = 0, lst = -1;
    for (int i = 0; i < n; i++) {
        if (xd[i]) lst = i;
        if (lst != -1 && pref[i + 1] - pref[lst] <= t) {
            best = max(best, i - lst + 1 + (t - pref[i + 1] + pref[lst]) / a[i]);
        }
    }
    lst = -1;
    for (int i = n - 1; i >= 0; i--) {
        if (xd[i]) lst = i;
        if (lst != -1 && pref[lst + 1] - pref[i] <= t) {
            best = max(best, lst - i + 1 + (t - pref[lst + 1] + pref[i]) / a[i]);
        }
    }
    cout << best << '\n';
}

signed main() {
    int tt = 1;
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        cin >> tt;
    #else
        cin.tie(0)->sync_with_stdio(false);
    #endif  

    while (tt--) {
        solve();
    }

    return 0;
}