object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, m, k = sc.nextInt
  val A = List.fill(n)(sc.nextInt)
  val B = List.fill(m)(sc.nextInt)

  val dA = maximum(A, k)
  val dB = maximum(B, k - dA.sum)

  val result = one(dA, dB)
  println(result)

  def maximum(desk: List[Int], sum: BigInt): List[Int] = {
    if (desk.map(BigInt(_)).sum <= sum) {
      desk
    } else {
      maximum(desk.init, sum)
    }
  }

  def one(deskA: List[Int], deskB: List[Int]): Int = {
    if (deskA.isEmpty) {
      deskB.length
    } else {
      val ifB = maximum(B, k - deskA.init.sum)
      if (ifB.length <= deskB.length || deskA.isEmpty) {
        deskA.length + deskB.length
      } else {
        one(deskA.init, ifB)
      }
    }
  }

}