function Main(input) {
    input = input.trim().split('\n');
    const n = parseInt(input[0].split(' ')[2], 10);
    const a = input[1].split(' ');
    const b = input[2].split(' ');

    let i = 0, j = 0, ret = 0, ut = 0;
    while(i < a.length || j < b.length){
        booka = parseInt(a[i], 10);
        bookb = parseInt(b[j], 10);
        if(booka < bookb) {
            i++;
            ut += booka;
        } else if(booka > bookb) {
            j++;
            ut += bookb;
        } else if(booka == bookb) {
            i++;
            ut += booka;
        }else if(!booka) {
            j++;
            ut += bookb;
        }else if(!bookb) {
            i++;
            ut += booka;
        }
        if(ut <= n) {
            ret++;
        }else{
            break;
        }
    }
    console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));