'use strict';

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

    let bestCounts = [];

    let Atime = 0;
    for (let i = 0; i < N; i++) {
        Atime += A[i];
        if (Atime > K) {
            break;
        }
        let remain = K - Atime;
        let count = i + 1;
        for (let j = 0; j < M; j++) {
            remain -= B[j];
            if (remain < 0) {
                bestCounts.push(count);
                break;
            } else {
                count++;
            }
        }
        bestCounts.push(count);
    }

    bestCounts.sort((a, b) => b - a);

    const count = bestCounts.length ? bestCounts[0] : 0;

    console.log(String(count));

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