function main(input){
  input = input.split('\n');
  const [n, m, k] = input[0].split(' ').map(x=>Number(x));
  const a = input[1].split(' ').map(x=>Number(x)).reverse();
  const b = input[2].split(' ').map(x=>Number(x)).reverse();

  // console.log(n, m, k);
  // console.log(a);
  // console.log(b);
  let count = 0;
  let totalTime = 0;
  while(totalTime <= k){
    let next;
    if(a[a.length-1] <= b[b.length-1]){
      next = a.pop();
    }else{
      next = b.pop();
    }
    totalTime += next;
    count++;
  }

  console.log(count-1);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));