import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main {

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val k = sc.nextLong()
    val a = ArrayBuffer.fill(n)(sc.nextLong())
    val b = ArrayBuffer.fill(m)(sc.nextLong())

    var cnt = 0
    var time = 0L

    while (time < k) {
        if (a.isEmpty && b.isEmpty) {
          time = k
        } else if (a.isEmpty) {
          time += b.head
          b.remove(0)
          if(time <= k) cnt += 1
        } else if (b.isEmpty) {
          time += a.head
          a.remove(0)
          if(time <= k) cnt += 1
        } else {
          if (a.head > b.head) {
            time += b.head
            b.remove(0)
            if(time <= k) cnt += 1
          } else {
            time += a.head
            a.remove(0)
            if(time <= k) cnt += 1
          }
        }
    }

    println(cnt)

  }
}
