#include <stdio.h>
int A[20000000];
int n;

int count(){//要素の数を数える
  int i;
  for(i=1;A[i]!=0;i++){
  }
  return i;
}

void maxHeapify( int i )
{
  int l,r,large,tmp,k;
  l=2*i;
  r=2*i+1;
   k=count();
  if(l<= k && A[l] > A[i]) large=l;
  else large=i;

  if(r<= n && A[r] > A[large]) large=r;

  if(large!=i){
    tmp=A[i];
    A[i]=A[large];
    A[large]=tmp;
    maxHeapify(large);
  }
}

void insert(int k){
  int i;
  for(i=1;A[i]!=0;i++){
  }
  A[i]=k;
  
}

int extractMax(){
  int i,max;
  for(i=1;A[i]!=0;i++){
  }
  n=i;
 maxHeapify(1);
 if(A[1]>A[n-1]){
 max=A[1];
 A[1]=A[n-1];
 }
 else{
 max=A[n-1];
 A[n-1]=A[1];
 }

 
  n--;
  maxHeapify(1);
  
  return max;
}




int main(){
  int i, x;
  char com[20];

  for ( i = 1; i <= 2000000; i++ ){
    scanf("%s", com);
     if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
     else if ( com[1] == 'x' ){
       printf("%d\n",extractMax());
    } 
     else if ( com[1] == 'n' ) break;
  }

 
  return 0;
}