var h,hs = 0;

function insert(key){
    h[++hs] = key;

    var i = hs;

    while(h[i] > h[Math.floor(i / 2)]){
        var ex = h[i];
        h[i] = h[Math.floor(i / 2)];
        h[Math.floor(i / 2)] = ex;
        i = Math.floor(i / 2);
    }
}

function extract(){
    if(hs <= 0)
        return;

    var ret = h[1];

    h[1] = h[hs--];

    i = 1;
    while((i * 2 <= hs && h[i] < h[i * 2]) || (i * 2 + 1 <= hs && h[i] < h[i * 2 + 1])){
        var l = i * 2;var r = i * 2;
        if(i * 2 + 1 <= hs)
            r++;
        var m = h[l] > h[r] ? l : r;
        var ex = h[i];
        h[i] = h[m];
        h[m] = ex;
        i = m;

    }
    return ret;
}



function Main(input){
    input = input.split("\n");
    h = new Array(2000000001);h[0] == 2000000001;

    var i = 0;
    while(1){
        if(input[i].charAt(0) == "i"){
            input[i] = input[i].split(" ");
            insert(parseInt(input[i][1],10));
        }else if(input[i].charAt(1) == "x"){
           console.log(extract());
        }else{
            break;
        }
        i++;

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