import Foundation
// Decimal型の有効桁数は38桁
let line = readLine()!.components(separatedBy: " ").map { Int($0)! }
let N = line[0]
let M = line[1]
let K = line[2]
var A = readLine()!.components(separatedBy: " ").map { Int($0)! }
var B = readLine()!.components(separatedBy: " ").map { Int($0)! }

A.append(Int.max)
B.append(Int.max)

var indexA = 0
var indexB = 0
var time = 0

while (indexA + indexB < N + M) {
    if A[indexA] <= B[indexB] {
        time += A[indexA]
        if K < time { break }
        indexA += 1
    } else {
        time += B[indexB]
        if K < time { break }
        indexB += 1
    }
}
print(indexA + indexB)
