function Main(input) {
  input = input.trim().split("\n").map(function(x) { return x.split(" ")});
  var L1 = input[0].map(e => parseInt(e, 10));
  var N = L1[0];
  var M = L1[1];
  var K = L1[2];
  var vec_A = input[1].map(e => parseInt(e, 10));
  var vec_B = input[2].map(e => parseInt(e, 10));
  var tmpAi = 0;
  var tmpBi = 0;
  var sumTime = 0;
  var ans = 0;
  var tmpBook;
  while (tmpAi < N || tmpBi < M){
    if (tmpAi === N) tmpBook =1;
    else if (tmpBi === N) tmpBook =0;
    else if (vec_A[tmpAi] > vec_B[tmpBi]) tmpBook = 1;
    else if (vec_A[tmpAi] <= vec_B[tmpBi]) tmpBook = 0;

    if (tmpBook === 0) {
      sumTime += vec_A[tmpAi];
      tmpAi ++;
    }
    if (tmpBook === 1) {
      sumTime += vec_B[tmpBi];
      tmpBi ++;
    }
    if (sumTime <= K) ans ++;  
    else break;
  }
  console.log(ans);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));