object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N, M, K = in.nextInt
  val As = List.fill(N)(in.nextLong)
  val Bs = List.fill(M)(in.nextLong)

  def takeRead(unread: List[Long], time: Long, cnt: Int, read: List[Long]): (List[Long], Long, Int) = unread match {
    case Nil => (read, time, cnt)
    case x :: xs =>
      if (time + x > K) (read, time, cnt)
      else takeRead(xs, time + x, cnt + 1, x :: read)
  }

  def dropRead(unread: List[Long], time: Long, cnt: Int): (List[Long], Long, Int) = unread match {
    case Nil => (unread, time, cnt)
    case x :: xs =>
      if (time + x > K) (unread, time, cnt)
      else dropRead(xs, time + x, cnt + 1)
  }


  def readBs(readAs: List[Long], unreadBs: List[Long], time: Long, cnt: Int, cntMax: Int): Int = readAs match {
    case Nil => cntMax
    case x :: xs =>
      val (newUnreadBs, newTime, newCnt) = dropRead(unreadBs, time - x, cnt - 1)
      readBs(xs, newUnreadBs, newTime, newCnt, cntMax max newCnt)
  }

  val (as, time, cnt) = takeRead(As, 0L, 0, Nil)
  println(readBs(0L :: as, Bs, time, cnt + 1, cnt))
}