'use strict';

function Main(input) {
    const tmp = input.trim().split('\n');
    const [N, M, K] = tmp[0].split(' ').map((v) => Number(v));
    const A = tmp[1].split(' ').map((v) => Number(v));
    const B = tmp[2].split(' ').map((v) => Number(v));

    let readBooksNums = [];

    // A=0冊
    let timeB = 0;
    let countB = 0;
    for (let i = 0; i < M; i++) {
        if (K - timeB < B[i]) {
            break;
        }
        timeB += B[i];
        countB++;
    }
    readBooksNums.push(countB);

    // A=1冊〜
    let timeA = 0;
    for (let i = 0; i < N; i++) {
        if (K - timeA < A[i]) {
            break;
        }
        timeA += A[i];
        const remain = K - timeA;
        if (remain < timeB && countB !== 0) {
            for (let j = countB - 1; j >= 0; j--) {
                timeB -= B[j];
                countB -= 1;
                if (remain >= timeB) {
                    break;
                }
            }
        }
        readBooksNums.push(countB + i + 1);
    }

    const result = readBooksNums.reduce((a, b) => Math.max(a, b));

    console.log(String(result));

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