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 result = (1 to n)
    .map(i => maximum(A.take(i), k))
    .map(dA => dA.length + maximum(B, k - dA.sum).length)
    .max

  println(result)

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