function main(input) {
  const [n, m, k] = input[0].trim().split(" ").map(i => parseInt(i));
  const a = input[1].trim().split(" ").map(i => parseInt(i));
  const b = input[2].trim().split(" ").map(i => parseInt(i));

  const a_sum = [0];
  const b_sum = [0];

  a.map((i,index)=>{
    a_sum[index+1]=a_sum[index]+i;
  });
  b.map((i,index)=>{
    b_sum[index+1]=b_sum[index]+i;
  });

  let ans = 0;
  let j = m;

  for(let i=0; i<n+1;i++){
    if(a_sum[i]>k){
      break;
    }
    while(b_sum[j] > k-a_sum[i]){
      j-=1;
    }
    ans = Math.max(ans, i+j)
  }
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));