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(): Long = {
    readBook(A, B, 0, k)
  }

  def readBook(a: Array[Long], b: Array[Long], readCnt: Long, restMin: Long): Long = {
    if(!canRead(a, restMin) && !canRead(b, restMin)) readCnt
    else {
      val readA = if(canRead(a, restMin)) readBook(a.drop(1), b, readCnt+1, restMin - a.head) else 0
      val readB = if(canRead(b, restMin)) readBook(a, b.drop(1), readCnt+1, restMin - b.head) else 0
      Math.max(readA, readB)
    }
  }

  def canRead(books: Array[Long], restMin: Long): Boolean = {
    if(books.isEmpty) false
    else books.head <= restMin
  }


  println(solve())

}
