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

#pragma GCC optimize("O3")

using namespace std;
//using namespace __gnu_pbds;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define int long long

//typedef tree<int, null_type,less<int>,  rb_tree_tag, tree_order_statistics_node_update> ordered_set;

signed main(){
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
    int n, m, T;
    cin>>n>>m>>T;
    vector<int> a(n);
    for(auto &x:a) cin>>x;
    vector<int> b(m);
    for(auto &x:b) cin>>x;
    int ans = 0;
    for(int i = 0; i < m; ++i){
        int j = b[i]-1;
        int p = 0, cnt = 0;
        for(int k = j; k >= 0; --k){
            if (p + a[k] > T) break;
            p += a[k];
            cnt += 1;
            ans = max(ans, cnt + max(0ll, T - p)/a[k]);
        }
        p = cnt = 0;
        for(int k = j; k < n; ++k){
            if (p + a[k] > T) break;
            p += a[k];
            cnt += 1;
            ans = max(ans, cnt + max(0ll, T - p)/a[k]);
        }
    }
    cout<<ans<<'\n';
    return 0;
}
