#include<bits/stdc++.h>
#define INF 2147483640
using namespace std;
long long a[200005],b[200005];
int main()
{
	//freopen("out.txt","w",stdout);
	int n,m,k,ans=0;
	cin >> n >> m >> k;
	for(int i=1; i<=n; i++) {cin >> a[i]; a[i]=a[i]+a[i-1];}
	for(int i=1; i<=m; i++) {cin >> b[i]; b[i]=b[i]+b[i-1];}
	int j=m;
	for(int i=0; i<=n; i++)
	{
		if(a[i] > k) break;
		while(j > 0 && a[i] + b[j] > k) j--;
		ans=max(ans,i+j);
		//cout << i << ' ' << j << '\n';
	}
	cout << ans;
	return 0;
}