function main(lines) {
  const [N, M, K] = splitN(lines[0]);
  const A = splitN(lines[1]);
  const B = splitN(lines[2]);
  
  let t = K, i = 0;
  while (t-A[i] >= 0) {
    t -= A[i];
    i++;
  }

  let res = i, j = 0;
  while (true) {
    while (t-B[j] >= 0) {
      t -= B[j];
      j++;
    }
    res = Math.max(res, i+j);
    if (!i) break;
    t += A[i-1];
    i--;
  }
  
  console.log(res);
}


main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );



function splitN(s) {
  return s.split(' ').map(Number);
}