import scala.math.max

object Main extends App{
  val sc = new java.util.Scanner(System.in)
  val N, M, K = sc.nextInt
  val A = Array.fill(N)(sc.nextLong)
  val B = Array.fill(M)(sc.nextLong)
  var t: Long = A.sum
  var idx = N - 1
  var ans = 0
  var tmp = N
  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)
}