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 vec_SumA = [];
  var vec_SumB = [];
  var tmp = 0;
  for (var i = 0; i < N; i++) {
    tmp += vec_A[i];
    if (tmp > K) break;
    vec_SumA.push(tmp);
  }
  tmp = 0;
  for (var i = 0; i < M; i++) {
    tmp += vec_B[i];
    if (tmp > K) break;
    vec_SumB.push(tmp);
  }
  var ans = vec_SumB.length;
  var tmpDepthB = vec_SumB.length - 1;
  for (var i = 0; i < vec_SumA.length; i++){
    while ((tmpDepthB !== -1) && (vec_SumB[tmpDepthB] + vec_SumA[i] > K)){
      tmpDepthB --;
      
    }
    ans = Math.max(ans, i + tmpDepthB + 2);
  }
  console.log(ans);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
