import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt()
  val m = sc.nextInt()
  val k = sc.nextInt()
  sc.nextLine()
  val as = sc.nextLine().split(' ').map(_.toInt)
  val bs = sc.nextLine().split(' ').map(_.toInt)

  var aCursor = 0
  var bCursor = 0
  var totalMinutes = 0
  var totalBook = 0

  def go: Int = {
    while (true) {
      if (aCursor >= n && bCursor >= m) {
        return totalBook
      } else if (aCursor >= n) {
        val nextTotal = totalMinutes + bs(bCursor)
        if (nextTotal > k) {
          return totalBook
        } else {
          totalMinutes = nextTotal
          bCursor += 1
          totalBook += 1
        }
      } else if (bCursor >= m) {
        val nextTotal = totalMinutes + as(aCursor)
        if (nextTotal > k) {
          return totalBook
        } else {
          totalMinutes = nextTotal
          aCursor += 1
          totalBook += 1
        }
      } else {
        if (as(aCursor) <= bs(bCursor)) {
          val nextTotal = totalMinutes + as(aCursor)
          if (nextTotal > k) {
            return totalBook
          } else {
            totalMinutes = nextTotal
            aCursor += 1
            totalBook += 1
          }
        } else {
          val nextTotal = totalMinutes + bs(bCursor)
          if (nextTotal > k) {
            return totalBook
          } else {
            totalMinutes = nextTotal
            bCursor += 1
            totalBook += 1
          }
        }
      }
    }
    0
  }

  val res = go
  println(res)
}
