func readInt() -> Int {
    return Int(readLine()!)!
}

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 mainC() {
    let (N, M, K) = readThreeInts()
    let A = readInts()
    let B = readInts()

    var spentTime = 0
    var count = 0
    var aIndex = 0
    var bIndex = 0

    while spentTime < K {
        if aIndex == N, bIndex == M { break }
        let a = aIndex >= N ? Int.max : A[aIndex]
        let b = bIndex >= M ? Int.max : B[bIndex]

        if a < b {
            if spentTime + a <= K {
                spentTime += a
                aIndex += 1
            } else {
                break
            }
        } else {
            if spentTime + b <= K {
                spentTime += b
                bIndex += 1
            } else {
                break
            }
        }

        count += 1
    }

    print(count)
}

mainC()