import java.util.Scanner

object Main extends App {

  def readALine(c:Int, ac:List[Int]=Nil):List[Int] =
    if (c > 0) readALine(c-1, sc.nextInt::ac) else ac.reverse
  // def readLines(r:Int, c:Int, ac:List[List[Int]]):List[List[Int]] =
  //   if (r > 0) readLines(r-1, c, readALine(c, Nil)::ac) else ac.reverse
  val sc = new Scanner(System.in)
  val N,M,K = sc.nextInt
  val Ai = readALine(N)
  val Bi = readALine(M)

  def solver(al:List[Int], bl:List[Int], ac:Int, count:Int):Int = {
    (al, bl) match {
      case (Nil, Nil) => count
      case (a::as, Nil) => if (ac+a > K) count else solver(as, Nil, ac+a, count+1)
      case (Nil, b::bs) => if (ac+b > K) count else solver(Nil, bs, ac+b, count+1)
      case (a::as, b::bs) => {
        val selectA = if (ac+a > K) count else solver(as, bl, ac+a, count+1)
        val selectB = if (ac+b > K) count else solver(al, bs, ac+b, count+1)
        if (selectA > selectB) selectA else selectB
      } 
    }
  }

  // println(s"Ai:$Ai Bi:$Bi")
  println(solver(Ai, Bi, 0, 0))

}