#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using sll = __int128;

template <typename T>
istream &operator>>(istream &in, pair<T, T> &a){
    in >> a.first >> a.second;
    return in;
}

template <typename T>
ostream &operator<<(ostream &out, pair<T, T> &a){
    out << a.first << ' ' << a.second;
    return out;
}

template <typename T>
istream &operator>>(istream &in, vector<T> &a){
    for(auto &x : a) in >> x;
    return in;
}

template <typename T>
ostream &operator<<(ostream &out, vector<T> &a){
    for(auto x : a) out << x << ' ';
    return out;
}

void solve(){
    int n, m, T;
    cin >> n >> m >> T;
    vector<ll> a(n + 1);
    for(int i = 1; i <= n; i++) cin >> a[i];
    vector<int> b(m + 1);
    for(int i = 1; i <= n; i++) cin >> b[i];
    vector<ll> pref(n + 1);
    for(int i = 1; i <= n; i++){
        pref[i] = pref[i - 1] + a[i];
    }
    int mx = 0;
    for(int i = 1; i <= m; i++){
        auto pos = b[i];
        int l = 0, r = pos;
        while(r - l > 1){
            int mid = (l + r) / 2;
            if(pref[pos] - pref[mid] <= T){
                r = mid;
            } else {
                l = mid;
            }
        }
//        cout << l << ' ' << r << '\n';
        int cur = pos - r + (T - (pref[pos] - pref[r])) / a[r];
        mx = max(mx, cur);
    }
    cout << mx;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int test = 1;
//    cin >> test;
    while(test--){
        solve();
    }
}

