inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')

const K = Number(inp[0].split(" ")[2])
const timeA = inp[1].split(" ").map(e => parseInt(e, 10))
const timeB = inp[2].split(" ").map(e => parseInt(e, 10))
let timer = 0
let counter = 0
while (timer <= K){
    if (timer + timeA[0] <= K || timer + timeB[0] <= K){
        if (timeA.length === 0 && timeB.length ===0 ){
            break
        } else if (timeA.length === 0 || timeB.length !== 0){
            timer += timeB[0]
            timeB.shift()
            counter ++
        } else if (timeA[0] >= timeB[0]){
            timer += timeB[0]
            timeB.shift()
            counter ++
        } else if (timeB.length === 0 || timeA.length !== 0){
            timer += timeA[0]
            timeA.shift()
            counter ++
        } else if (timeA[0] < timeB[0]){
            timer += timeA[0]
            timeA.shift()
            counter ++
        }
    } else {
        break
    }
}
console.log(counter)
