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

using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
        tree_order_statistics_node_update>;
template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag,
        tree_order_statistics_node_update>;

#define int long long


signed main() {
    int n, m, t;
    cin >> n >> m >> t;
    vector<int> a(n), b(m);
    vector<int> pref(n + 1);
    pref[0] = 0;
    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];
        b[i]--;
    }
    int r = 0;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (r < m) {
            if (i > b[r]) {
                r++;
            }
        }
        if (r > 0) {
            int dt = t - (pref[i] - pref[b[r - 1]]);
            if (dt >= 0) {
                ans = max(ans, i - b[r - 1] + dt / a[i]);
            }
        }
        if (r < m) {
            int dt = t - (pref[b[r] + 1] - pref[i + 1]);
            if (dt >= 0) {
                ans = max(ans, b[r] - i + dt / a[i]);
            }
        }
    }
    cout << ans;
    return 0;
}
