#include <bits/stdc++.h>

#define endl '\n'
#define PI acos(-1.0)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	priority_queue<size_t> p;
	while(true) {
		string cmd;
		cin >> cmd;
		
		if(cmd == "end") break;
		
		if(cmd == "insert") {
			int x;
			cin >> x;
			p.push(x);
		} else {
			cout << p.top() << endl;
			p.pop();
		}
	}
	
	return 0;
}

