#include <stdio.h>
#include <string.h>

void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

#define MAX_H 500000

int H;
int Q[MAX_H];

void maxHeapify(int idx) {
  int l = 2*idx+1;
  int r = 2*idx+2;
  int largest = idx;
  if(l < H && Q[largest] < Q[l]) largest = l;
  if(r < H && Q[largest] < Q[r]) largest = r;
  
  if(largest != idx) {
    swap(Q+idx, Q+largest);
    maxHeapify(largest);
  }
}

void buildMaxHeap() {
  int i;
  for(i = H/2; i >= 0; i--) maxHeapify(i);
}

int heapMaximum() {
  return Q[0];
}

int ExtractMax() {
  if(H < 1) return -1;
  int max = heapMaximum();
  Q[0] = Q[H-1];
  H--;
  maxHeapify(0);
  return max;
}

void heapIncreaseKey(int idx, int key) {
  if(key < Q[idx]) return;
  Q[idx] = key;
  while(idx > 0 && Q[(idx-1)/2] < Q[idx]) {
    swap(Q+idx, Q+(idx-1)/2);
    idx = (idx-1)/2;
  }
}

void maxHeapInsert(int key) {
  H++;
  Q[H-1] = -1;
  heapIncreaseKey(H-1, key);
}

int main() {
  int i;
  char buf[256];
  H = 0;
  while(scanf("%s", buf), strcmp(buf, "end") != 0) {
    if(strcmp(buf, "insert") == 0) {
      int k;
      scanf("%d", &k);
      maxHeapInsert(k);
    } else if(strcmp(buf, "extract") == 0) {
      printf("%d\n", ExtractMax());      
    }
  }
  
  return 0;
}