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

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