let input = "3 8 730\n60 90 120\n80 150 80 150 11 11 11 11 11";

function main(input){
	input = input.trim();
 	let N = parseInt(input.split("\n")[0].split(" ")[0]);
 	let M = parseInt(input.split("\n")[0].split(" ")[1]);
	let K = parseInt(input.split("\n")[0].split(" ")[2]);
  
	let nBooks = input.split("\n")[1].split(" ");
  	for(let i=0; i<nBooks.length; i++){nBooks[i] = parseInt(nBooks[i]);}
	let mBooks = input.split("\n")[2].split(" ");
  	for(let i=0; i<mBooks.length; i++){mBooks[i] = parseInt(mBooks[i]);}
  
 	function getRuiseki(books){
 	  	let ruiseki = 0;
		let Yomu = [];
  		for(let i=0; ruiseki<=K; i++){
          ruiseki += books[i];
          if(ruiseki<=K){Yomu.push(ruiseki);}
        }
      	return(Yomu);
    }

	let nBooksKei = getRuiseki(nBooks);
	let mBooksKei = getRuiseki(mBooks);
 
  	nBooksKei.unshift(0);
  	mBooksKei.unshift(0);
 /* 
  	console.log(K);
	console.log(nBooksKei);
 	console.log(mBooksKei);
  */
	let kiroku = 0;
 	let sinKiroku = 0;
  	let bestJ = M;
 	for(let i=0; i<nBooksKei.length; i++){
      for(let j=bestJ; j>-1; j--){
        if(nBooksKei[i] + mBooksKei[j] <= K){
          	kiroku = i + j;
          	bestJ = j;
          	// console.log(i + ":" + j);
        	if(kiroku>sinKiroku){sinKiroku=kiroku;}
            break;
        }
      }
    }
  	console.log(sinKiroku);
}
//main(input);
main(require("fs").readFileSync("/dev/stdin", "utf8"));
