#include <iostream>
 #include<bits/stdc++.h>

using namespace std ;



int main(){
	priority_queue<int> q;
	string s;
	int n;
	while(cin>>s){
		if(s=="end") break;
		if(s =="insert"){
			cin>>n;
			q.push(n);
		}
		else{
			cout<<q.top()<<endl;
			q.pop();
		}
	}
}
