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

A.append(Decimal(string: "10000000000")!)
B.append(Decimal(string: "10000000000")!)

var indexA = 0
var indexB = 0
var time = Decimal(string: "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)
