#include<stdio.h>
#define MAX 2000000

int sise, X[MAX+1];

void maxHeapify(int i){
  int l, r, largest, t;
  l = 2*i;
  r = 2*i+1;
  if ( l <= sise && X[l] > X[i] ) 
    largest = l;
  else 
    largest = i;
  if ( r <= sise && X[r] > X[largest] ) 
    largest = r;
  if ( largest != i ){
    t = X[i];
    X[i] = X[largest]; 
    X[largest] = t;
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if ( sise < 1 )
    return;
  maxv = X[1];
  X[1] = X[sise--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key){
  int tmp;
  if ( key < X[i] ) 
    return;

  X[i] = key;
  while ( i > 1 && X[i/2] < X[i] ){
    tmp = X[i];
    X[i] = X[i/2];
    X[i/2] = tmp;
    i = i/2;
  }
}

void insert(int key){
  sise++;
  X[sise] = -1000000001;
  increaseKey(sise, key);
}

main(){
  int key;
  char com[20];
  while(1){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &key);
      insert(key);
    } 
    else if ( strcmp(com, "extract") == 0  ){
      printf("%d\n", extract());
    }
    else
         break;
  }

  return 0;
}
