import Foundation
let line = readLine()!.components(separatedBy: " ")
let N = Int(line[0])!
let M = Int(line[1])!
let K = Double(line[2])!
var A = readLine()!.components(separatedBy: " ").map { Double($0)! }
var B = readLine()!.components(separatedBy: " ").map { Double($0)! }

var indexA = 0
var indexB = 0
var time: Double = 0

while (true) {
    switch (indexA < N, indexB < M) {
    case (true, true):
        if A[indexA] <= B[indexB] {
            time += A[indexA]
            if K < time {
                print(indexA + indexB)
                exit(EXIT_SUCCESS)
            }
            indexA += 1
        } else {
            time += B[indexB]
            if K < time {
                print(indexA + indexB)
                exit(EXIT_SUCCESS)
            }
            indexB += 1
        }
    case (true, false):
        time += A[indexA]
        if K < time {
            print(indexA + indexB)
            exit(EXIT_SUCCESS)
        }
        indexA += 1
    case (false, true):
        time += B[indexB]
        if K < time {
            print(indexA + indexB)
            exit(EXIT_SUCCESS)
        }
        indexB += 1
    default:
        print(indexA + indexB)
        exit(EXIT_SUCCESS)
    }
}
