const main = args =>{
  const [N, M, K] = split_string(args[0]);
  const A = split_string(args[1]);
  const B = split_string(args[2]);
  
  let A_i=0, B_i=0, res=0, count=0;
  while(ture){
  	if(A[A_i]<B[B_i]){
		res += A[A_i];
      	if(res>K){
        	console.log(count);
          	return;
        }
      	A_i++;
    }else{
    	res += B[B_i];
      	if(res>K){
        	console.log(count);
          	return;
        }
      	B_i++;
    }
    count++;
  }
}

const split_string = s => {
  return s.split(' ').map(Number);
}
 
main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );
 
 
 
