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]);}
  

	let kiroku = 0;
 	let sinKiroku = 0;
  	let nKei = 0;
  	let mKei = 0;
  	let goukei = 0;
  	nBooks.unshift(0);
    mBooks.unshift(0);
 
    //console.log(nBooks); console.log(mBooks);
  
  	for(let i=0; (nKei<=K && i<nBooks.length); i++){
      nKei += nBooks[i];
      goukei = nKei;
      for(let j=0; (goukei<=K && j<mBooks.length); j++){
        goukei += mBooks[j];
        if(goukei>K){break;}
        kiroku = i + j;
        console.log(goukei+" "+i+"("+nKei+") "+j+"("+(goukei-nKei)+") "+kiroku);
        if(kiroku>sinKiroku){sinKiroku=kiroku;}
      }
    }
  
  	console.log(sinKiroku);
}
//main(input);
main(require("fs").readFileSync("/dev/stdin", "utf8"));
