object Main {
  def main(args: Array[String]): Unit = {
    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())

    var left_K = K
    var A_idx = 0
    var B_idx = 0

    while(A_idx <= N && B_idx <= M &&
          scala.math.min(
            (if(A_idx != N) A(A_idx) else 1e9+1),
            (if(B_idx != M) B(B_idx) else 1e9+1)) <= left_K){

      if(B_idx == M || (A_idx != N && A(A_idx) < B(B_idx))) {
        left_K = left_K - A(A_idx)
        A_idx = A_idx + 1
      }
      else {
        left_K = left_K - B(B_idx)
        B_idx = B_idx + 1
      }
    }
    println(A_idx + B_idx)
  }
}
