#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>;

void solve() {
    int n, m, T;
    cin >> n >> m >> T;
    vector<int> a(n);
    vector<int> b(m);
    vector<ll> pref(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        pref[i + 1] = pref[i] + a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        auto p = lower_bound(b.begin(), b.end(), i + 1);
        if (p != b.end()) {
            int pos = *p - 1;
            ll t = pref[pos + 1] - pref[i];
            if (T >= t) {
                ans = max(ans, pos - i + 1 + (T - t) / a[i]);
            }
        }
        if (p != b.begin()) {
            int pos = *--p - 1;
            ll t = pref[i + 1] - pref[pos];
            if (T >= t) {
                ans = max(ans, i - pos + 1 + (T - t) / a[i]);
            }
        }
    }
    cout << ans;
}

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