"use strict";

const main = arg => {
    const inputList = arg.trim().split("\n");
    // 回答を記述
    const N = parseInt(inputList[0].split(" ")[0]);
    const M = parseInt(inputList[0].split(" ")[1]);
    const K = parseInt(inputList[0].split(" ")[2]);
    const A = inputList[1].split(" ").map(ele => parseInt(ele));
    const B = inputList[2].split(" ").map(ele => parseInt(ele));

    if (K < A[0] && K < B[0]) {
        console.log(0);
    } else {

        let addA = [0]
        for (let i = 0; i < N; i++) {
            addA.push(addA[i] + A[i])
        }
        console.log(addA)

        let addB = [0]
        for (let i = 0; i < M; i++) {
            addB.push(addB[i] + B[i])
        }
        console.log(addB)

        let result = 0;
        let k = M;
        for (let j = 0; j < addA.length; j++) {
            if (addA[j] > K) {
                break;
            }

            while (addB[k] > K - addA[j]) {
                k--;
            }
            result = Math.max(result, j + k);
        }
        console.log(result)
    }

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