const readLines = (input) => input.split('\n')
const println = (value) => console.log(value)
const readInt = (input) => parseInt(input, 10)
const readIntList = (input) => input.split(' ').map(n => parseInt(n, 10))
const naturalOrder = (a, b) => {
    if (b == a) return 0
    return (a < b) ? -1 : 1
}

function main(input) {
    const lines = readLines(input)
    const [n, m, k] = readIntList(lines[0])
    const aArray = readIntList(lines[1])
    const bArray = readIntList(lines[2])

    // 片方を選んだときに、もう片方をどこまで読めるのかを二分探索する
    const accumb = [0]
    for (let i = 0; i < m; i++) {
        accumb.push(accumb[i] + bArray[i])
    }

    let aTime = 0
    let ans = 0
    let aCount = 0
    for (a of [0].concat(aArray)) {
        aTime += a

        let left = -1
        let right = accumb.length
        while (right - left > 1) {
            const mid = Math.floor((right + left) / 2)
            if (aTime + accumb[mid] <= k)
                left = mid
            else
                right = mid
        }

        // println(aTime)
        // println(accumb[left])
        // println(aTime + accumb[left])
        // println(left)
        // println()
        if (left != -1) ans = Math.max(ans, left + aCount)
        aCount++
    }

    println(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
