object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N,M,K = sc.nextInt()
    val A = List.fill(N)(sc.nextInt())
    val B = List.fill(M)(sc.nextInt())
    val sumA = A.scan(0)(_ + _)
    val sumB = B.scan(0)(_ + _)

    var ans = 0;
    var j = M;
    for(i <- 0 to N){
      if(sumA(i) < K) {
        while (sumB(j) > K - sumA(i)) j = j - 1
        ans = scala.math.max(ans, i + j)
      }
    }
    println(ans)
  }
}
