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

const int N = 5e5 + 22;
int n, m, T, a[N], b[N];
bool ex[N];

int brut() {
    int ans = 0;
    for (int i = 1; i <= m; i++) {
        int cur = T;
        for (int j = b[i]; j <= n; j++) {
            cur -= a[j];
            if (cur < 0) break;
            ans = max(ans, j - b[i] + cur / a[j] + 1);
        }

        cur = T;
        for (int j = b[i]; j >= 1; j--) {
            cur -= a[j];
            if (cur < 0) break;
            ans = max(ans, b[i] - j + cur / a[j] + 1);
        }
    }
    return ans;
}

int32_t main() {
    srand(time(0));
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
    cin >> n >> m >> T;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= m; i++) {cin >> b[i]; ex[b[i]] = 1;}
    // for (int i = 1; i <= n; i++) a[i] = rand() % 100 + 1;
    // for (int i = 1; i <= m; i++) {b[i] = rand() % n + 1; ex[b[i]] = 1;}

    int ans = 0, cur = 0, prev = 0;
    for (int i = 1; i <= n; i++) {
        if (prev == 0 || T - cur - a[i] < 0 || T / a[i] > (T - cur - a[i]) / a[prev] + abs(i - prev)) {
            if (ex[i]) ans = max(ans, T / a[i]);
            cur = 0;
            prev = i;
        } else {
            cur += a[i];
            if (ex[i] && T - cur >= 0) ans = max(ans, (T - cur) / a[prev] + abs(i - prev));
        }
    }
    cur = 0, prev = 0;
    for (int i = n; i >= 1; i--) {
        if (prev == 0 || T - cur - a[i] < 0 || T / a[i] > (T - cur - a[i]) / a[prev] + abs(i - prev)) {
            if (ex[i]) ans = max(ans, T / a[i]);
            cur = 0;
            prev = i;
        } else {
            cur += a[i];
            if (ex[i] && T - cur >= 0) ans = max(ans, (T - cur) / a[prev] + abs(i - prev));
        }
    }

    // cout ln;
    // for (int i = 1; i <= n; i++) cout << a[i] << ' '; cout ln;
    // for (int i = 1; i <= n; i++) cout << b[i] << ' '; cout ln;
    // cout << ans << ' ' << brut() ln;
    // if (ans != brut()) return 0;
    cout << ans;
    return 0;
}

/*
5 5 14
26 9 91 99 8
2 2 4 1 4
*/