#include<stdio.h>
#define MAX 2000001
#define LEN  8
#define INFTY -1


int h = 0;
int a[MAX];



void heapIncreaseKey(int key, int i){
  int parent = i / 2;
  int v;

  if(key < a[h]) return;
  a[h] = key;

  while(i > 1 && a[parent] < a[i]){
    v = a[i];
    a[i] = a[parent];
    a[parent] = v;
    i = parent;
    parent = i / 2;
  }
}

void insert(int key){
  h++;
  a[h] = INFTY;
  heapIncreaseKey(key, h);
}



void maxHeapify(int i){
  int l, r;
  int largest;
  int v;

  l = 2 * i;
  r = 2 * i + 1;


  if(l <= h && a[l] > a[i]) largest = l;
  else largest = i;
  if(r <= h && a[r] > a[largest]) largest = r;


  if(largest != i){
    v = a[i];
    a[i] = a[largest];
    a[largest] = v;
    maxHeapify(largest);
  }
}



int extractmax(){
  int max;
  if(h < 1) return 0;
  max = a[1];
  a[1] = a[h];
  h--;
  maxHeapify(1);
  return max;
}


int main(){
  char c[LEN];
  int key;

  while(1){
    scanf("%s", c);
    if(c[0] == 'e' && c[1] == 'n') break;
    else if(c[0] == 'i'){
      scanf("%d", &key);
      insert(key);
    }
    else{
      printf("%d\n", extractmax());
    }
  }

  return 0;
}

