    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 = read(A, B, 0, 0)
      println(result)
     
      @scala.annotation.tailrec
      def read(da: List[Int], db: List[Int], sum: BigInt, count: Int): Int = {
        val nextA = headOrDeka(da) <= headOrDeka(db)
        val next = math.min(headOrDeka(da), headOrDeka(db))
        val total = sum + next
        if (total > k || next == Int.MaxValue){
          count
        } else {
          if (nextA) {
            read(da.tail, db, total, count + 1)
          } else {
            read(da, db.tail, total, count + 1)
          }
        }
      }
     
      def headOrDeka(list: List[Int]) :Int = list.headOption.getOrElse(Int.MaxValue)
     
    }