object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N, M, K = sc.nextInt()
  val as = Array.fill(N)(sc.nextLong()).scanLeft(0L)(_ + _)
  val bs = Array.fill(M)(sc.nextLong()).scanLeft(0L)(_ + _)

  @scala.annotation.tailrec
  def loop(diff: Long, j: Int): Int = if (diff < bs(j)) loop(diff, j - 1) else j

  val counts = for {
    i <- 0 to N
    if as(i) <= K
  } yield i + loop(K - as(i), M)

  println(counts.max)
}
