"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 = []
        for (let i = 0; i < N; i++) {
            addA[i] = A[i] + (addA[i - 1] ? addA[i - 1] : 0)
        }

        let addB = []
        for (let i = 0; i < M; i++) {
            addB[i] = B[i] + (addB[i - 1] ? addB[i - 1] : 0)
        }

        if ((addA[addA.length - 1] + addB[addB.length - 1]) <= K) {
            console.log(addA.length + addB.length)
        } else {
            let result = 0;
            for (let j = 0; j < addA.length; j++) {
                let num = addA[j];
                for (let k = 0; k < addB.length; k++) {
                    let num2 = addB[k];
                    if ((num + num2) <= K) {
                        result = Math.max(result, j + k + 2)
                    } else {
                        break;
                    }
                }

            }

            console.log(result)
        }
    }

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