process.stdin.resume();
process.stdin.setEncoding('utf8');
var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
});
reader.on('line', (line) => {
    lines.push(line);
});
reader.on('close', () => {
    const [N, M, K] = lines[0].split(" ").map(e => parseInt(e));
    lines.shift();
    const listA = lines[0].split(" ").map(e => parseInt(e));
    lines.shift();
    const listB = lines[0].split(" ").map(e => parseInt(e));

    let remain = K;
    let iA = 0;
    let iB = 0;
    let cnt = 0;
    while (true) {
        let vA = iA >= N ? 10000000000 : listA[iA];
        let vB = iB >= M ? 10000000000 : listB[iB];
        if (vA < vB){
            if (remain >= vA){
                remain = remain - vA;
                cnt++;
                iA++;
            } else {
                break;
            }
        } else {
            if (remain >= vB){
                remain = remain - vB;
                cnt++;
                iB++;
            } else {
                break;
            }
        }
    }
    console.log(cnt);
});