function main(arg) {
    let lines = arg.split("\n")
    let [n,m,k] = lines[0].split(" ").map(x=>parseInt(x))
    let a = lines[1].split(" ").map(x=>parseInt(x))
    let b = lines[2].split(" ").map(x=>parseInt(x))

    let dp = []
    for(let i=0; i<n+m; i++) {
        dp[i] = 0
    }
    
    let aCount=0, bCount=0
    if(Math.min(a[aCount], b[bCount]) > k) {
        
    } else {
        let whichMin = a[0]<b[0] ? 0 : 1 //0: A is min, 1: B is min
        for(let i=0; i<n+m; i++) {
            let addA = 0, addB = 0
            if(whichMin===0) {
                //dp[i+1] = dp[i] + Math.min(a[aCount], b[bCount])
                dp[i+1] = dp[i] + a[0]
                addA=1
                a.shift()
            } else {
                dp[i+1] = dp[i] + b[0]
                addB=1
                b.shift()
            }
            //console.log(`---aCount=${aCount}, bCount=${bCount}`)
            //console.log(`a[aCount] = ${a[aCount]}, b[bCount] = ${b[bCount]}`)
            //console.log(`dp[${i}+1]=${dp[i+1]}`)

            if(dp[i+1] > k) {
                break
            }
            if(!a.length && !b.length)break

            aCount += addA
            bCount += addB
            //console.log(`a[aCount] = ${a[0]}, b[bCount] = ${b[0]}`)
            if(a[0] > b[0]) {
                whichMin = 1
            } else {
                whichMin = 0
            }
    
        }
    }
    console.log(aCount+bCount)


}

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