#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
using ll = long long;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, m, t;
    cin >> n >> m >> t;

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

    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }

    vector <ll> ans(n);

    int j = 0;
    for (int i = 0; i < n; i++) {
        while (pref[i+1] - pref[j+1] > t) {
            j++;
        }
        ans[i] = (t - pref[i+1] + pref[j+1]) / a[j] + (i - j);
    }

    ll res = 0;
    for (int i = 0; i < m; i++) {
        res = max(res, ans[b[i] - 1]);
    }

    cout << res << '\n';
}

/*

*/