"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)
    let ans = 0
    let sum = 0
    let a = 0
    let b = 0
    for (;;) {
        let v
        if (N === a && M === b) {
            break
        }
        if (N === a) {
            v = B[b]
            b++
            if (sum + v > K) {
                break
            }
            sum += v
            ans++
        } else if (M === b) {
            v = A[a]
            a++
            if (sum + v > K) {
                break
            }
            sum += v
            ans++
        } else {
            v
            if (A[a] > B[b]) {
                v = B[b]
                b++
            } else {
                v = A[a]
                a++
            }
            if (sum + v > K) {
                break
            }
            sum += v
            ans++
        }
        // console.log(v)
    }
    console.log(ans)
    // console.log(sum)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));