"use strict"
function main(arg) {
    let [N,M,K] = arg.trim().split("\n")[0].split(" ").map(Number)
    let A = arg.trim().split("\n")[1].split(" ").map(Number)
    let B = arg.trim().split("\n")[2].split(" ").map(Number)
    N = A.length
    M = B.length
    K = BigInt(K)
    let ans = 0
    let sum = 0
    let a = 0
    let b = 0
    let aSum = BigInt(0)
    let bSumList = new Array(B.length).fill(0)
    let bSum = BigInt(0)
    for (b = 0; b < M; b++) {
        bSum += BigInt(B[b])
        bSumList[b] = bSum
    }
    for (a = 0; a < N; a++) {
        aSum += BigInt(A[a])
        // console.log(aSum)
        // let bSum = BigInt(0)
        for (b = 0; b < M; b++) {
            bSum = bSumList[b]
            if (aSum + bSum > K) {
                break
            }
            ans = Math.max(ans, (a+1) + (b+1))
            // console.log([ans,a+1,b+1])
        }
    }
    console.log(ans)
    // console.log(sum)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
