#include<bits/stdc++.h>
using namespace std;
long long N,M,K,ans,a[200005],b[200005];
int main(){
	cin>>N>>M>>K;
	for(long long i=1;i<=N;i++)cin>>a[i],a[i]=a[i-1]+a[i];
	for(long long i=1;i<=M;i++)cin>>b[i],b[i]=b[i-1]+b[i];
	for(long long i=0;i<=N;i++)
		if(K>=a[i])
			ans=max(ans,upper_bound(b+1,b+M+1,K-a[i])-b-1+i);
	cout<<ans;
}
