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