#if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

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

