object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N, M = sc.nextInt()
  val K = sc.nextLong()
  val as = Array.fill(N)(sc.nextLong()).scanLeft(0L)(_ + _).takeWhile(_ <= K + 1)
  val bs = Array.fill(M)(sc.nextLong()).scanLeft(0L)(_ + _).takeWhile(_ <= K + 1)
  val counts = for {
    i <- as.indices
    j <- bs.indices
    if as(i) + bs(j) <= K
  } yield i + j
  println(counts.max)
}
