import java.util.Scanner
import scala.math.max

object Main extends App{
  val sc = new Scanner(System.in)
  val N, M, K = sc.nextInt
  val A = List.fill(N)(sc.nextInt)
  val B = List.fill(M)(sc.nextInt)
  var t: Long = 0
  var idx = -1
  for(i <- 0 until N){
    if(t + A(i) <= K){
      t += A(i)
      idx += 1
    }
  }
  var ans, tmp = idx + 1
  for(i <- 0 to M){
    if(i != 0){
      t += B(i - 1)
      tmp += 1
    }
    while(t > K && idx >= 0){
      t -= A(idx)
      idx -= 1
      tmp -= 1
    }
    if(t <= K) ans = max(ans, tmp)
  }
  println(ans)
}