let main = (input) => {
    let usrInput = input.split(/\n/)
    let sample = usrInput[0].split(/\s+/).map(Number)
    let bookA = usrInput[1].split(/\s+/).map(Number)
    let bookB = usrInput[2].split(/\s+/).map(Number)

    let book = 0
    for (let time = 0; time < sample[2];) {
        if (bookA.length !== 0 && bookB.length !== 0) {
            if (bookA[0] < bookB[0]) {
                if (time + bookA[0] <= sample[2]) {
                    time += bookA.shift()
                    book++
                } else
                    break
            } else {
                if (time + bookB[0] <= sample[2]) {
                    time += bookB.shift()
                    book++
                } else
                    break
            }
        }
        if (bookA.length === 0 && bookB.length !== 0) {
            if (time + bookB[0] <= sample[2]) {
                time += bookB.shift()
                book++
            }
        }
        if (bookB.length === 0 && bookA.length !== 0) {
            if (time + bookA[0] <= sample[2]) {
                time += bookA.shift()
                book++
            }
        }

        if (bookB.length === 0 && bookA.length === 0)
            break
    }

    console.log(book)
}

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