// Created by rost on 08.03.25.

#include <bits/stdc++.h>

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

void first(int n, int m, int t, vector<int> &a, vector<int> &b) {
    vector<ll> prefSum(n + 1);
    for (int i = 0; i < n; ++i)
        prefSum[i + 1] = prefSum[i] + a[i];

    ll res = 0;
    for (auto start: b) {
        for (int i = 0; i < start && t - prefSum[start + 1] + prefSum[i + 1] >= 0; ++i)
            res = max(res, start - i + (t - prefSum[start + 1] + prefSum[i + 1]) / a[i]);
        for (int i = start; i < n; ++i)
            res = max(res, i - start + (t + prefSum[start] - prefSum[i]) / a[i]);
    }
    cout << res << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

#ifdef LOCAL
    freopen("in.in", "r", stdin);
    freopen("out.out", "w", stdout);
#endif

    bool second = true;

    int n, m, t;
    cin >> n >> m >> t;
    vector<int> a(n), b(m);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];

        if (i != 0 && a[i - 1] > a[i])
            second = false;
    }
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
        --b[i];
    }

    if (n <= 1000) {
        first(n, m, t, a, b);
    } else if (second) {
        vector<int> _b = {b[0]};
        first(n, 1, t, a, _b);
    } 
}