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 a = [0]
    let b = [0]
    for(let i=0; i<n; i++) {
        a.push(a[i]+A[i])
    }
    for(let i=0; i<m; i++) {
        b.push(b[i]+B[i])
    }
    
    let ans=0, j=m
    for(let i=0; i<=n; i++) {
        if(a[i] > k)break;
        while(b[j] > k-a[i]) {
            j--
        }
        ans = Math.max(ans, i+j)
    }
    console.log(ans)
}

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