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 time = 0
    for (time = 0; time < sample[2];) {
        if (bookA[0] < bookB[0]) {
            time += bookA.shift()
        }
        else {
            time += bookB.shift()
        }
    }

    console.log(time)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))