#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

// #define FILE
#define int long long



signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m, T;
    cin >> n >> m >> T;
    vector<int> a(n), b(m);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
        b[i]--;
    }
    vector<int> pref(n + 1);
    for (int i = 1; i <= n; ++i) {
        pref[i] = pref[i - 1] + a[i - 1];
    }
    int ans = 0;
    for (auto i : b) {
        ans = max(ans, T / a[i]);
        int l = -1, r = i;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            int sum = pref[i + 1] - pref[mid + 1];
            if (sum <= T) {
                r = mid;
            } else {
                l = mid;
            }
        }
        int sum = pref[i + 1] - pref[r + 1];
        ans = max(ans, i - r + (T - sum) / a[r]);
    }
    cout << ans;
}