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 (indexA + indexB < N + M) {
    switch (indexA < N, indexB < M) {
    case (true, true):
        if A[indexA] <= B[indexB] {
            time += A[indexA]
            if K < time { break }
            indexA += 1
        } else {
            time += B[indexB]
            if K < time { break }
            indexB += 1
        }
    case (true, false):
        time += A[indexA]
        if K < time { break }
        indexA += 1
    case (false, true):
        time += B[indexB]
        if K < time { break }
        indexB += 1
    default:
        break
    }
}

print(indexA + indexB)
