#include <stdio.h>
#include <string.h>
#define N 2000000

int a[N];
int size;

void MaxHeapify(int i){
  int l, r, x, largest;
  l = i*2;
  r = i*2+1;
  if(l <= size && a[l] > a[i]){
    largest = l;
  }else{
    largest = i;
  }
  if(r <= size && a[r] > a[largest]){
    largest = r;
  }
  if(largest != i){
    x = a[i];
    a[i] = a[largest];
    a[largest] = x;
    MaxHeapify(largest);
  }
}

void HeapIncreaseKey(int i, int key){
  int x;
  if(key < a[i]){
    fprintf(stderr, "新しいキーは現在のキーより小さい\n");
  }
  a[i] = key;
  while(i > 1 && a[i/2] < a[i]){
    x = a[i];
    a[i] = a[i/2];
    a[i/2] = x;
    i = i/2;
  }
}

void maxHeapInsert(int key){
  size = size + 1;
  a[size] = -2147483648;
  HeapIncreaseKey(size, key);
}

int HeapExtractMax(void){
  if(size < 1){
    fprintf(stderr, "ヒープアンダーフロー\n");
  }
  int max;
  max = a[1];
  a[1] = a[size];
  size = size-1;
  MaxHeapify(1);
  return max;
}

int main(){
  int i = 0, k, max;
  char c[10];
  char *a = "insert";
  char *b = "extract";
  char *d = "end";

  size = 0;
  while(1){
    scanf("%s", c);
    if(strcmp(c, a) == 0){
      scanf("%d", &k);
      maxHeapInsert(k);
    }else if(strcmp(c, b) == 0){
      max = HeapExtractMax();
      printf("%d\n", max);
    }else if(strcmp(c, d) == 0){
      break;
    }
  }

  return 0;
}

