func readThreeInts(separator: String.Element = " ") -> (a: Int, b: Int, c: Int) {
    let ints = readLine()!.split(separator: separator).map { Int($0)! }
    return (a: ints[0], b: ints[1], c: ints[2])
}

func readInts(separator: String.Element = " ") -> [Int] {
    return readLine()!.split(separator: separator).map { Int($0)! }
}

func mainC() {
    let (N, M, K) = readThreeInts()
    let A = readInts()
    let B = readInts()

    // Nまでの和を出しておく、forの中でreduceをやるとo(n^2)で間に合わない
    var a = [0]
    for i in 0..<N {
        a.append(a[i] + A[i])
    }

    var b = [0]
    for i in 0..<M {
        b.append(b[i] + B[i])
    }

    var answer = 0
    var j = M
    for i in 0...N {
        if a[i] > K { break }

        while b[j] > K - a[i] {
            j -= 1
        }

        answer = max(answer, i + j)
    }

    print(answer)
}

mainC()