object Main {

  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)
    val Array(n,m,k) = scanner.nextLine().split(" ").map(_.toInt)
    val arr_a = scanner.nextLine().split(" ").map(_.toInt)
    val arr_b = scanner.nextLine().split(" ").map(_.toInt)

    def oneDeskReadBook(arr:Array[Int], index:Int, index_max:Int, ct:Int, current_acc:Int):Int = {
      if(index >= index_max)
        current_acc
      else{
        val newcurrentTime = ct + arr(index)
        if(newcurrentTime > k)
          current_acc
        else
          oneDeskReadBook(arr, index+1, index_max, newcurrentTime, current_acc+1)
      }
    }
    def readbook(index_a:Int, index_b:Int, currentTime:Int, acc:Int):Int = {
      if(index_a >= n){
        oneDeskReadBook(arr_b, index_b, m, currentTime, acc)
      }
      else if(index_b >= m){
        oneDeskReadBook(arr_a, index_a, n, currentTime, acc)
      }
      else {
        if (arr_a(index_a) <= arr_b(index_b)) {
          val newcurrentTime = currentTime + arr_a(index_a)
          if (newcurrentTime > k)
            acc
          else
            readbook(index_a + 1, index_b, newcurrentTime, acc + 1)
        }
        else {
          val newcurrentTime = currentTime + arr_b(index_b)
          if (newcurrentTime > k)
            acc
          else
            readbook(index_a, index_b + 1, newcurrentTime, acc + 1)
        }
      }
    }

    println(readbook(0, 0, 0, 0))
  }
}
