'use strict'

function main(input) {
    let n = Number(input.split('\n')[0].split(' ')[0]);
    let m = Number(input.split('\n')[0].split(' ')[1]);
    let k = Number(input.split('\n')[0].split(' ')[2]);
    let A = [];
    let B = [];
    let sumTimes = 0;
    let count = 0;
    for (let i = 0; i < n; i++) {
        A[i] = Number(input.split('\n')[1].split(' ')[i]);
    }
    for (let k = 0; k < m; k++) {
        B[k] = Number(input.split('\n')[2].split(' ')[k]);
    }
    for (let i = 0; ; ) {
        if (A[i] == null && B[i] == null) {
            break;
        }
        if (A[i] > B[i] || A.length === 0) {
            let _b = B.shift()
            if (sumTimes + _b > k) {
                break;
            }
            sumTimes += _b;
        } else if (A[i] <= B[i] || B.length === 0) {
            let _a = A.shift();
            if (sumTimes + _a > k) {
                break;
            }
            sumTimes += _a;
        }
        count++;
    }
    console.log(count);
}

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