include<stdio.h>
#include<limits.h>
int num,tmp;
int S[20000000];


int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}



void heapIncreaseKey(int i,int key){
  if(S[i]>key){
    return ;
  }


  S[i]=key;
  while(i>1 && S[parent(i)]<S[i]){
    tmp=S[i];
    S[i]=S[parent(i)];
    S[parent(i)]=tmp;
    i=parent(i);
  }
}



void maxHeapInsert(int key){
  num=num+1;
  S[num]=-1000;
  heapIncreaseKey(num,key);
}



void maxHeapify(int i){
  int l,r,largest,tmp;
  l= left(i);
  r =right(i);
  if(l<=num && S[l]>S[i])largest =l;
  else largest =i;
  if(r<=num &&S[r]>S[largest])largest=r;
  if(largest != i){
    tmp=S[i];
    S[i]=S[largest];
    S[largest]=tmp;
    maxHeapify(largest);
  }
}

//?????§?????????????????? S ???????´???? S ????????????????????????????????????                                                                                                                                                                                    

int heapExtractMax(){
  int Max;

  if(num<1){
    return 0;
  }

  Max=S[1];
  S[1]=S[num];
  num=num-1;
  maxHeapify(1);
  return Max;
}


int main(){
 char b[100];
 int j;
  while(1){
    scanf("%s",b);
    if(b[0] =='i') {
      scanf("%d",&j);
      maxHeapInsert(j);
              }

    else if(b[1]=='x'){
      printf("%d\n",heapExtractMax());
      }
 else break;
    }

      return 0;
}