const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {

    const lines = input.split('\n')
    const [N, M, K] = lines[0].split(' ').map(Number)
    const A = lines[1].split(' ').map(Number)
    const B = lines[2].split(' ').map(Number)

    let t = 0
    const max = A.length + B.length
    let a = 0
    let b = 0
    for (var i = 0; i < max; i++) {
        if (!B[b] || A[a] < B[b]) {
            t += A[a]
            a++
        } else {
            t += B[b]
            b++
        }
        if (t > K) {
            break
        }
    }

    console.log(i)

})(input)
