import java.util.Scanner

import scala.io.StdIn._
object Main extends App {

  val Array(n, m, k) = scala.io.StdIn.readLine().split(" ").map(_.toLong)
  val A = scala.io.StdIn.readLine().split(" ").map(_.toLong)
  val B = scala.io.StdIn.readLine().split(" ").map(_.toLong)

  def solve() = {
    val cumulativeA = A.scan(0L)(_ + _)
    val cumulativeB = B.scan(0L)(_ + _)

    (0 to n.toInt).foldLeft(0) { (acc, i) =>
      if(cumulativeA(i) <= k) {
        var j = m.toInt
        while(cumulativeB(j) > k - cumulativeA(i))
          j -= 1
        Math.max(acc, i+j)
      } else acc
    }
  }


  println(solve())

}

