
console.log((args=>{
  const [[N,M,K],A,B] = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0) );
  const sA = [0], sB = [0];
  for ( let i = 0; i < N; i++ ) {
    sA.push( sA[i] + A[i] );
    if ( sA[i] > K ) break;
  } 
  for ( let i = 0; i < M; i++ ) {
    sB.push( sB[i] + B[i] );
    if ( sB[i] > K ) break;
  }
  let max = 0;
  for ( let i = 0; i < sA.length; i++ ) {
    for ( let j = 0; j < sB.length; j++ ) {
      if ( sA[i] + sB[j] > K ) break;
      if ( i + j > max ) max = i + j;
    }
  }
  return `${max}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));