function Main(input) {
    input = input.split("\n");
    const array = input[0].split(' ');
    const n = Number(array[0]);
    const m = Number(array[1]);
    const k = Number(array[2]);

    const array1 = input[1].split(' ');
    const array2 = input[2].split(' ');
    
    let num = 0;
    let time = 0;
    let count = m + n;

    for (let i = 0;  i < count; i++) {
       if (array1.length < 1) {
            time += Number(array2[0]);
            array2.shift();
        } else if (array2.length < 1) {
            time += Number(array1[0]);
            array1.shift();
        } else if (Number(array1[0]) <= Number(array2[0])) {
            time += Number(array1[0]);
            array1.shift();
        } else {
            time += Number(array2[0]);
            array2.shift();
        }

        if (time > k) {
            break;
        } else {
            num ++;
        }  
    }
    
    console.log(num);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));