#include <bits/stdc++.h>
using namespace std;

int main(void) {
	priority_queue<int> pq;
	string com;
	int k;
	cin >> com;
	while (com != "end") {
		if (com == "insert") {
			cin >> k;
			pq.push(k);
		} else if (com == "extract") {
			cout << pq.top() << endl;
			pq.pop();
		}
		cin >> com;
	}
}
