#include <stdio.h>

#define SWAP(x, y) ((x) += (y), (y) = (x) - (y), (x) -= (y))
#define PARENT(x) (x / 2)
#define LEFT(x) (2 * x)
#define RIGHT(x) (2 * x + 1)

int heap_size, a[1000000];

void maxHeapify(int *a,int i){
  int l = LEFT(i), r = RIGHT(i), largest;
  if(l <= heap_size && a[l] > a[i]) largest = l;
  else largest = i;
  if(r <= heap_size && a[r] > a[largest]) largest = r;
  if(largest != i){
    SWAP(a[i], a[largest]);
    maxHeapify(a, largest);
  }
  return;
}

void heapIncreaseKey(int *a, int i, int key){
  if(key < a[i]);
  a[i] = key;
  while(i > 1 && a[PARENT(i)] < a[i]){
    SWAP(a[i], a[PARENT(i)]);
    i = PARENT(i);
  }
  return;
}

void maxHeapInsert(int *a,int key){
  heap_size++;
  a[heap_size] = -100000;
  heapIncreaseKey(a, heap_size, key);
  return;
}

int heapExtractMax(int *a){
  if(heap_size < 1);
  int  max = a[1];
  a[1] = a[heap_size];
  heap_size--;
  maxHeapify(a, 1);
  return max;
}

int main(){
  int key, i, j;
  char op[10];

  while(scanf("%s", op) && strcmp(op, "end") != 0){
    if(op[0] == 'i'){
      scanf("%d", &key);
      maxHeapInsert(a, key);
    }else if(op[0] == 'e')
      printf("%d\n", heapExtractMax(a));
  }
  return 0;
}