func readIntArray() -> [Int] {
    readLine()!.split(separator: " ").map({Int($0)!})
}

let max = 10000000000
let line = readIntArray()
let (N, M, K) = (line[0], line[1], line[2])
let A = readIntArray() + [max]
let B = readIntArray() + [max]

var i = 0, j = 0
var time = 0
var count = 0
while time + A[i] <= K || time + B[j] <= K {
    count += 1
    if A[i] < B[j] {
        time += A[i]
        i += 1
    } else {
        time += B[j]
        j += 1
    }
}
print(count)
