
object Main extends App {
  val Array(n, m, k) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  val a = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  val s = scala.io.StdIn.readLine.split(" ").map(_.toInt)

  var max = 0

  var a_sum: BigInt = 0
  (0 to a.length).foreach { i =>
    if (i != 0) {
      a_sum += a(i - 1)
    }
    if (a_sum > k) {
      println(max)
      sys.exit(0)
    }

    var s_sum: BigInt = 0
    (0 to s.length).foreach { j =>
      if (j != 0) {
        s_sum += s(j - 1)
      }
      if (a_sum + s_sum <= k) {
        //  println("i " + i + " :" + a_sum)
        //  println("j " + j + " :" + s_sum)
        max = List(max, i + j).max
      }
    }
  }

  println(max)
}
