#include<stdio.h>
#include<limits.h>
int n,tmp,A[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(key<A[i]){
    return;
  }
  A[i]=key;
  while(i>1 && A[parent(i)]<A[i]){
    tmp=A[i];
    A[i]=A[parent(i)];
    A[parent(i)]=tmp;
    i=parent(i);
  }
}
void maxHeapInsert(int key){
  n=n+1;
  A[n]=INT_MIN;
  heapIncreaseKey(n,key);
}

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

int heapExtractMax(){
  int max;
  if(n<1){
    return 0;
  }
  max=A[1];
  A[1]=A[n];
  n=n-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;
}

  