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