#include<cstdio>
#include<queue>

int main() {
  char com[10];
  int key;
  std::priority_queue<int> PQ;

  while (1) {
    scanf("%s", com);
    if (com[0] == 'e' && com[1] == 'n') break;
    if (com[0] == 'i') {
      scanf("%d", &key);
      PQ.push(key);
    } else if (com[0] == 'e') {
      printf("%d\n", PQ.top());
      PQ.pop();
    }
  }

  return 0;
}

