#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast,unroll-loops")
using namespace std;
#define int long long
#define ns cout << "\n";
#define ld long double
const int INF=1e9+7,N=1e6;
vector<int>p(N,0);
int sum(int l,int r){
    if ( l>r){
        return 0;
    }
    return p[r+1]-p[l];
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n,m,t;
    cin>>n>>m>>t;
    vector<int>a(n),b(m);
    for (int i=0;i<n;++i){
        cin>>a[i];
        p[i+1]=a[i]+p[i];
    }
    for (int i=0;i<m;++i){
        cin>>b[i];
        b[i]--;
    }
    int w=0;
    for (int i=0;i<n;++i){
        if (i<b[0]){
            int x=b[m-1];
            int tt=t;
            tt-=sum(x,m-1);
            tt-=sum(0ll,i-1);
        
        }
        else{
            int x=*--upper_bound(b.begin(),b.end(),i);
            int tt=t;
            tt-=sum(x,i-1);
            if (tt>=0){
            w=max(w,(i-x)+tt/a[i]);
        }}
        if (i>b[m-1]){
            int x=b[0];
            int tt=t;
            tt-=sum(0,x);
            tt-=sum(i+1,n-1);
         }
        else{
            int x=*lower_bound(b.begin(),b.end(),i);
            int tt=t;
            tt-=sum(i+1,x);
            if (tt>=0){
            w=max(w,x-i+tt/a[i]);
        }}
        //cout<<i<<' '<<w<<endl;
    }    
    cout<<w;
}