import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
bool DEBUG = 0; void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void main(string[] args){ args ~= ["", ""]; string cmd = args[1]; if(cmd == "-debug") DEBUG = 1;
if(cmd == "-gen") gen; else if(cmd == "-jury") jury; else solve; } 
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ std.stdio.write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void gen(){}
void jury(){}
void solve(){
  int n = scan!int, m = scan!int;
  long k = scan!long;
  long[] as = scan!long(n);
  long[] bs = scan!long(m);
  
  long[] asum = [0], bsum = [0];
  foreach(a; as) asum ~= asum[$ - 1] + a;
  foreach(b; bs) bsum ~= bsum[$ - 1] + b;

  int ans;
  foreach(int i; 0 .. n + 1){
    if(asum[i] > k) break;
    int tmpans = i + uplimit(0, m, (int j) => asum[i] + bsum[j] <= k);
    ans.raiseTo(tmpans);
  }
  
  ans.writeln;
}


// 二分探索

// a 以上 c 以下の範囲で f(x) をみたす最大の x
// ただし、a がみたさない場合は a - 1 を返す ※範囲外エラーに注意
// f は単調減少であること
T uplimit(T)(T a, T c, bool delegate(T) f){
	if(f(c)) return c; if(! f(a)) return a - 1;
	while(a + 1 < c){ T b = (a + c) / 2; if(f(b)) a = b; else c = b; }
	return a;
}

// a 以上 c 以下の範囲で f(x) をみたす最小の x
// ただし、c がみたさない場合は c + 1 を返す ※範囲外エラーに注意
// f は単調増加であること
T downlimit(T)(T a, T c, bool delegate(T) f){
	if(f(a)) return a; if(! f(c)) return c + 1;
	while(a + 1 < c){ T b = (a + c) / 2; if(f(b)) c = b; else a = b; }
	return c;
}

