'use strict';
function Main(stdin){
  const input = stdin.trim().split(/\r?\n/g);
  const N = Number(input[0].split(' ')[0]);
  const M = Number(input[0].split(' ')[1]);
  const K = Number(input[0].split(' ')[2]);
  let A = input[1].split(' ').map(str => Number(str));
  let B = input[2].split(' ').map(str => Number(str));
  let sum = 0;
  let count = 0;

  if(A[0] > K && B[0] > K) sum = K;
  A.reverse();
  B.reverse();
  let Ad;
  let Bd;
  while(sum < K){
    if(A.length === 0 || B.length === 0){
      if(B.length > 0){
        sum += B.pop();
      } else if (A.length > 0) {
        sum += A.pop();        
      } else {
        break;
      }
    } else {
      Ad = A.pop();
      Bd = B.pop();
      if(Ad <= Bd){ 
        sum += Ad;
        B.push(Bd);
      } else {
        sum += Bd;
        A.push(Ad);
      }
    }
    if(sum < K) count++;
  }
  console.log(count);
}

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