object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N, M = sc.nextInt()
  val K = sc.nextLong()
  val as = Array.fill(N)(sc.nextLong())
  val bs = Array.fill(M)(sc.nextLong())

  def maxCount: Long = {
    var max = 0L

    def loop(i: Int, j: Int, remaining: Long, count: Long): Unit = {
      if (i == as.length && j == bs.length) max = count
      else if (remaining < 0) max = max.max(count - 1)
      else {
        if (i < as.length) loop(i + 1, j, remaining - as(i), count + 1)
        if (j < bs.length) loop(i, j + 1, remaining - bs(j), count + 1)
      }
    }

    loop(0, 0, K, 0)
    max
  }

  println(maxCount)
}
