#include <stdio.h>

int H,s[1000000];
void insert(int key)
{
  H++;
  s[H]=-1;
  heapIncreasekey(H,key);
}
 
int heapExtractMax(void)
{
  int max;
   
  if(H<1) return;
   
  max=s[1];
  s[1]=s[H];
  H--;
  maxHeapify(s,1);
   
  return max; 
}
 
void heapIncreasekey(int i,int key)
{
  int temp;
   
  if(key<s[i]) return;
 
  s[i]=key;
  while(i>1 && s[i/2]<s[i]){
    temp=s[i];
    s[i]=s[i/2];
    s[i/2]=temp;
    i=i/2;
  }
}
 
void maxHeapify(int A[],int i)
{
  int l,r,largest,temp;
 
  l = i*2;
  r = l+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){  
    temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    maxHeapify(A, largest);
  }      
}
int main()
{
  int i,key;
  char cmd[10];
 
  while(1){
    scanf("%s",cmd); 
    if(cmd[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    else if(cmd[1]=='x') printf("%d\n",heapExtractMax());
    else break;
  }
   
  return 0;
}
 