#include<stdio.h>
#define N 2000001

int p=0,A[N];

int max_index(int a,int b){
  
  if(A[a]>A[b])return a;
  
  else return b;
  
}

void swap(int a,int b){
  
  int tmp;
  tmp=A[a];
  A[a]=A[b];
  A[b]=tmp;
}


void insert(int k){
  int i,j;
  p++;
  A[p]=k;
  i=p;
  
  while(A[i]>A[i/2] && i>1){
    
    swap(i,i/2);
    i=i/2;
  }
}
int extract(){
  int res=A[1],i,sum;
  
  A[1]=A[p];
  p--;
  i=1;
  
  while(i*2 <= p ){
    
    if(i*2+1 <= p)
      
      sum=max_index(i*2,i*2+1);
    else sum=i*2;
    
    if(max_index(sum,i)==sum){
      
      swap(sum,i);
      i=sum;
    }
    else break;
     
  }
  
  return res;
}
int main(){
  char B[10];
  int i,j,k;
  
  while(1){
    
    scanf("%s",B);
    if(B[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }
    
    if(B[0]=='e'){
      if(B[1]=='x')
	
    printf("%d\n",extract());
      if(B[1]=='n') break;
    }
  }
  
  return 0;
}

