#include <stdio.h>
#define error -1
int size=0,list[2000000];

int parent(int i){
   return i/2;
}

int Left(int i){
  return 2*i;
 }

int Right(int i){
  return 2*i+1;  
 }

void maxHeapify(int i){
  int left,right,largest,key;
  left=Left(i);
  right=Right(i);
  
  if(left<=size && list[left]>list[i])
    largest=left;
  else largest=i;
  
  if(right<=size && list[right]>list[largest])
    largest=right;
  
  if(largest!=i){
    key=list[i];
    list[i]=list[largest];
    list[largest]=key;
    maxHeapify(largest);
  }  
}







void heapIncrease(int i,int key){
  int ch;
  if(key<list[i]) return;
  list[i]=key;
  while(i>0 && list[parent(i)]<list[i]){
    ch=list[i];
    list[i]=list[parent(i)];
    list[parent(i)]=ch;
    i=parent(i);
  }
  return;
}


void insert(int key){
  size=size+1;
  list[size]=-1000000;
  heapIncrease(size,key);
}


int heapExtractMax(){
  int max;
  if(size<0) return error;
  max=list[0];
  list[0]=list[size];
  size=size-1;
  maxHeapify(0);
  return max;
}
 
int main(){
  char Inst[10];
  int count,del,key;
 
 while(1){
   
   scanf("%s %d",Inst,&key);
   if(Inst[0]=='i') insert(key);
   else if(Inst[1]=='x'){
     del=heapExtractMax();
     printf("%d\n",del);
   }
   else if(Inst[2]=='d') break;

 }
 return 0;
}