#include <bits/stdc++.h>
using namespace std;
int main(){
    char com[20];
    int i;
    priority_queue<int> PQ;
    while(1){
        scanf("%s",com);
        if(com[0]=='i'){
            scanf("%d",&i);
            PQ.push(i);
        }
        else if(com[1]=='x'){
            cout << PQ.top() << endl;
            PQ.pop();
        }
        else if(com[0]=='e'){
            break;
        }
    }
    return 0;
}
