// 累積和 + 二分探索
// x以下を満たす最大のインデックスを返す二分探索
func binarySearch(_ x: Int) -> Int{
    var (l, r): (Int, Int) = (0, NMK[1]+1)

    while r-l > 1 {
        let i: Int = (l + r) / 2

        if csumB[i] >= x {
            r = i
        } else {
            l = i
        }
    }
    return l
}

let NMK: [Int] = readLine()!.split(separator: " ").map { Int($0)! }
let As: [Int] = readLine()!.split(separator: " ").map { Int($0)! }
let Bs: [Int] = readLine()!.split(separator: " ").map { Int($0)! }

var sum: Int = 0
let csumA: [Int] = [0] + As.map { sum += $0; return sum }
sum = 0
let csumB: [Int] = [0] + Bs.map { sum += $0; return sum }
var (a, b, res): (Int, Int, Int) = (0, 0, 0)

for a in 0...NMK[0] {
    if csumA[a] > NMK[2] { break }
    b = binarySearch(NMK[2]-csumA[a])
    res = max(res, a + b)
}
print(res)  // (๑•ૅㅁ•๑)