#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    priority_queue<int> q;
    while(cin>>s,s!="end"){
        if(s[0]=='i'){
            int n;
            cin>>n;
            q.push(n);
        }else{
            cout<<q.top()<<endl;
            q.pop();
        }
    }
}

