#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using ll = long long;
using namespace __gnu_pbds;
using ord_set = tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>;
#define int ll
void solve() {
    int n, m, T;
    cin >> n >> m >> T;
    vector<int> a(n), b(m);
    vector<ll> pref(n + 1);
    map<int, vector<int>> mapa;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mapa[a[i]].push_back(i);
        pref[i + 1] = pref[i] + a[i];
    }
    int ans = 0;
    for (int i = 0; i < m; i++) {
        cin >> b[i];
        b[i]--;
    }
    sort(b.begin(), b.end());
    for (int i = 0; i < 1; i++) {
        for (auto [val, vec] : mapa) {
            for (int pos : vec) {
                if (pos < b[i]) {
                    int t = pref[b[i] + 1] - pref[pos];
                    int cur = b[i] - pos + 1;
                    if (t > T) {
                        continue;
                    }
                    cur += (T - t) / val;
                    ans = max(ans, cur);
                } else if (b[i] < pos) {
                    int t = pref[pos + 1] - pref[b[i]];
                    int cur = pos - b[i] + 1;
                    if (t > T) {
                        continue;
                    }
                    cur += (T - t) / val;
                    ans = max(ans, cur);
                } else {
                    ans = max(ans, T / val);
                }
            }
        }
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int tt = 1;
//    cin >> tt;
    while (tt--) {
        solve();
    }
}
