// Problem : C - Tsundoku
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


/*when the going gets tough the tough gets going  */
/*we are what we repeatedly do , Excellence then is not an act but a habit  - aristotle */
/*The best way to predict the future is to create it - abraham lincoln*/
/*First think , second believe , third dream and finally dare - walt disney*/
/*It is during our darkest moments that we must focus to see the light */
/*Nothing is impossible the word itself says "i'm fucking possible man just try me again and again till i seem impossible "*/
/*Dont judge each day by the harvest you reap but by the seeds you plant */
/*Do not dwell in the past, do not dream of the future, concentrate the mind on the present moment*/
/*Success is not final failure is not fatal : it is the courage to continue that counts */ 
/*the future belongs to those who believe in the beauty of their dreams */
/*The pessimist complains about the wind , the optimist waits for it to change; the realist adjusts the sails  */
/*Believe you can and you are half way there */
/*Everything has beauty but not everyone sees it */
/*Life is not about finding yourself , life is about creating yourself*/
/*You are the average of the 5 people you spend the most time with .........*/
/*Everything is hard before it is easy see for example now the list of examples is very long hahahahahaha...... ......*/
/*I believe in miracles .......*/
#include<bits/stdc++.h>
#define LL long long 
#define pb push_back

#define PII pair<int , int > 
#define PLL pair<LL , LL >
#define LD long double
#define VLL vector<LL>
#define VPII vector<PII>
#define VI vector<int>
#define VPLL vector<PLL>
#define VLD vector<LD>
#define VVI vector<VI>
#define VVLL vector<VLL>
#define VVPLL vector<VPLL>
#define VVII vector<VPII>
#define IN insert
#define wht while (t--)
#define FU( i , a  , n ) for ( int i = (int)a ; i <=(int)n ; i++  )
#define FD( i , n , a ) for (int i = (int)n ; i >=(int)a ;i--)
#define REP(i,n) for ( int i = 0 ; i < (int)n;  i++)
#define FST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define SZ(a) int((a).size())
#define pi(n) printf("%d" , n ) 
#define pl(n) printf("%lld" , n )
#define ff first
#define ss second
#define ii(n) scanf("%d" , &n)
#define il(n) scanf("%lld" , &n )
#define LB lower_bound
#define UB upper_bound
#define BS binary_search
#define ALL(V) V.begin(), V.end()
#define ic(n) cin>>n
#define pr printf
#define INF 99999999
#define en endl
using namespace std ;
string str ;
const int tt = 0;
 void solve()
 {
 	int   m , n ,a , b ,c ;
 	LL k ;
 	cin>> n >> m>> k ;
 	VLL arr(n), brr(m);
 	REP(i, n) 
 	{
 		cin>>arr[i];
 		if (i)
 		{
 			arr[i] += arr[i-1];
 		} 
 		// arr.pb(a);
 	}
 	REP(i, m)
 	{
 		cin>> brr[i];
 		if (i)
 		{
 			brr[i] += (brr[i-1]);
 		}
 		// cout << brr[i] << " ";
 	}
 	LL ans = 0;
 	ans = UB(ALL(brr), k )- brr.begin();
 	// cout << ans<<" ";
 	REP(i, n)
 	{
 		if (arr[i] <= k )
 		{
 			LL temp = i+1 + (UB(ALL(brr), k - arr[i] ) - brr.begin() )  ;
 			ans = max(temp, ans);
 		}
 	}
 	cout << ans;
 }
int main()
{
	FST;
	
    if (tt)
    {
    	int t;
    	cin>> t ;
    	while (t--)
    	{
    		solve();
    	}
    }
    else
    {
    	solve();
    }
	return 0 ;
	
 
} 

Measured memory_bytes: 6328