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 find(array:Array[Int], key:Int):Int = {
    require(!array.isEmpty,"Array must have elements.")
    def iter(l:Int, r:Int):Int = {
      if (l == r) if (array(l) > key) l-1 else l
      val bound = (l+r)>>1
      // println(s"l:$l r:$r bound:$bound key:$key")
      array(bound) match {
        case v if v > key => if (array(bound-1) < key) bound-1 else iter(l-1, bound)
        case v if v < key => if (array(bound+1) > key) bound else iter(bound, r+1)
        case _ => bound
      }
    }

    val maxIdx = array.length-1
    key match {
      case k if k > array(maxIdx) => maxIdx
      case k if k < array(0) => -1
      case _ => iter(0, array.length-1) 
    }
  }

  def solver():Int = {
    def acumulate(list:List[Int], ac:List[Int]):List[Int] =
      if (list.isEmpty) ac
      else if (ac.isEmpty) acumulate(list.tail,list.head::ac)
      else acumulate(list.tail,(ac.head+list.head)::ac)
    val cumAi = acumulate(Ai, Nil).reverse.toArray
    val cumBi = acumulate(Bi, Nil).reverse.toArray
 
    // println(cumAi.mkString(","))
    // println(cumBi.mkString(","))
 
    def iter(i:Int, max:Int):Int = {
      if (i < cumAi.length && cumAi(i) < K) {
        val j = find(cumBi, K - cumAi(i))
        // println(s"i:$i j:$j max:$max")
        if (i+j+2 > max) iter(i+1, i+j+2) else iter(i+1, max)
      } else max
    }
    iter(0, 0)
  }

  println(solver())

}