function Main(input) {
    tmp = input.split("\n");
    tmp2 = tmp[0];
    tmp3 = tmp2.split(" ");

    n = parseInt(tmp3[0], 10);
    m = parseInt(tmp3[1], 10);
    k = parseInt(tmp3[2], 10);

    a = tmp[1];
    a = a.split(" ");
    b = tmp[2];
    b = b.split(" ");


    count = 0;
    time = 0;


    outer:
    while( k > time ){

        aa = parseInt(a[0], 10);
        aNaN = Number.isNaN(aa);
        bb = parseInt(b[0], 10);
        bNaN = Number.isNaN(bb);



        if (bNaN || aNaN) {

            if (aNaN) {
                if (k >= time + bb) {
                    time += bb;
                    b.shift();
                    count += 1;
                    bb = 0;
    
                } else{
                    break outer;
                }
                
            } else if (bNaN) {
                if (k >= time + aa) {
                    time += aa;
                    a.shift();
                    count += 1;
                    aa = 0;
  
                } else{
                    break outer;
                }
                
            }
            
        }


        // bの方が読書時間が短い
        if (aa > bb && bNaN == false ) {
            if (k > time + bb) {
                time += bb;
                b.shift();
                count += 1;
                bb = 0;
            } else{
                break outer;
            }
        } 
        // aの方が読書時間が短い
        else if (aa <= bb && aNaN == false ) {
            if (k > time + aa) {
                time += aa;
                a.shift();
                count += 1;
                aa = 0;
            } else{
                break outer;
            }
        } 

    }
  console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));