#include<stdio.h>
#define MAX 2000000

int size, T[MAX+1];

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

int extract(){
  int maxv;
  if ( size < 1 ) return;
  maxv = T[1];
  T[1] = T[size--];
  maxH(1);
  return maxv;
}

void incrKey(int j, int key){
  int tmp;
  if ( key < T[j] ) return;
  T[j] = key;
  while ( j > 1 && T[j/2] < T[j] ){
    tmp = T[j];
    T[j] = T[j/2];
    T[j/2] = tmp;
    j = j/2;
  }
}

void insert(int key){
  size++;
  T[size] = -1000000001;
  incrKey(size, key);
}

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