#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main() {
	int n,m,k;
	cin>>n>>m>>k;
	ll a[n+5],b[m+5];
	ll ans=0;
	for(int i=0;i<n;i++){
	    cin>>a[i];
	    if(i>0)a[i]+=a[i-1];
        if(a[i]<=k) ans=i+1;
	}
	
    ll temp=0;
    for(ll i=0; i<m; i++){
        cin>>b[i];
        temp+=b[i];
        if (temp>k) break;
        ll resto=k-temp;
        ll  in= upper_bound(a,a+n,resto)-a;
        ans=max(ans,in+i+1LL);
    }
    
    cout<<ans<<"\n";
	return 0;
}
