function Main(input){
  input = input.split("\n");
  let tmp = input[0].split(" ");
  let n = tmp[0];
  let m = tmp[1];
  let limit = parseInt(tmp[2]);
  let a = input[1].split(" ");
  let b = input[2].split(" ");

  let count = 0;
  let time = 0;
  if(parseInt(a[0])  > limit && parseInt(b[0])  > limit) console.log(0);
  else{
    while(time <= limit){
      let select = selectBook(a, b, 0, 0);
      if(a.length === 0) select = "b";
      if(b.length === 0) select = "a";
      if(a.length === 0 && b.length === 0) break;
      if(select === "a"){
        time += parseInt(a[0]);
        a.shift();
      }else{
        time += parseInt(b[0]);
        b.shift();
      }
      if(time > limit) break;
      count++;
    }
    console.log(count);
  }

  function selectBook (aa, bb, aai, bbi) {
    let select = "c";
    while(aai < aa.length && bbi < bb.length ){
      if(parseInt(aa[aai])<parseInt(bb[bbi])){
        select = "a";
        break;
      }else if(parseInt(aa[aai])>parseInt(bb[bbi])){
        select = "b";
        break;
      }else selectBook(aa, bb, aai+1, bbi+1);
    }
    if(select === "c") select = "a";
    return select;
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));