#include <stdio.h>
void buildMaxHeap(int*);
void maxHeapify(int*, int);
int extractMax(int*);
void insert(int*,int);
int H,A[2000000];
int main(){
  int k,i;
  char com[30];
  H=0;
  
  while(1){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&k);
      insert(A,k);
    }
    else if(com[1]=='x'){
      printf("%d\n",extractMax(A));
    }
    else break;
  }
  return 0;
}
void buildMaxHeap(int* A){
  int i;
  for(i=H/2;i>=1;i--)
    maxHeapify(A, i);
}
void maxHeapify(int*A, int i){
  int l,r,largest,B;
  l=2*i;
  r=2*i+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){
    B=A[i];
    A[i]=A[largest];
    A[largest]=B;
    maxHeapify(A, largest);
  }
}
int extractMax(int*A){
  int maxVal=A[1];
  A[1]=A[H];
  H--;
  maxHeapify(A, 1);
  return maxVal;
}
void insert(int*A,int k){
  int i,S;
  H++;
  A[H]=k;
  for(i=H;i!=1&&A[i]>A[i/2];i=i/2){
    S=A[i];
    A[i]=A[i/2];
    A[i/2]=S;
  }
}
  
  

