#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cstdint>
using namespace std;
#define int long long

void solution();

int32_t main() {
#ifdef LOCAL
    freopen("test", "r", stdin);
    freopen("out", "w", stdout);
#endif

    int t = 1;
    // cin >> t;
    while (t--) {
        solution();
    }
}

void solution() {
    int n, m, t;
    cin >> n >> m >> t;

    vector<int> a(n);
    for (auto &x : a) {
        cin >> x;
    }

    vector<int> b(m);
    for (auto &x : b) {
        cin >> x;
        x--;
    }

    vector<int> p(n + 1);
    for (int i = 0; i < n; ++i) {
        p[i + 1] = p[i] + a[i];
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        auto lb = lower_bound(b.begin(), b.end(), i);
        if (lb != b.begin()) {
            int prev = *(--lb);
            ++lb;
            if (p[i] - p[prev] <= t) {
                ans = max(ans, i - prev + (t - (p[i] - p[prev])) / a[i]);
            }
        }
        if (lb != b.end()) {
            int next = *lb;
            if (p[next + 1] - p[i + 1] <= t) {
                ans = max(ans, next - i + (t - (p[next + 1] - p[i + 1])) / a[i]);
            }
        }
    }

    cout << ans << '\n';
}