#include <stdio.h>
#define INFTY (1<<30)

int H,A[2000001];

void maxHeapify(int i){
  int l,r,largest,tmp;;
  l=i*2;
  r=i*2+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){
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(largest);
  }
}


int heapExtractMax(){
  int max;
  if(H<1) return -INFTY;
  max = A[1];
  A[1] = A[H--];
  maxHeapify(1);
       return max;
}

void heapIncreaseKey(int i,int key){
  int tmp;
  if (key < A[i]) return;
  A[i] = key;
  while (i > 1 && A[i/2] < A[i]){
    tmp=A[i];
    A[i]=A[i/2];
    A[i/2]=tmp;
    i = i/2;
  }
}

void maxHeapInsert(int key){
  H++;
  A[H]=-INFTY;
  heapIncreaseKey(H,key);
}

int main(){
  int key;
  char order[10];
  int i=1;

  while(1){
  scanf("%s",order);
  if(order[0]=='i'){
    scanf("%d",&key);
    maxHeapInsert(key);
  }
  if(order[0]=='e' && order[1] != 'n') printf("%d\n",heapExtractMax());
  if(order[0]=='e' && order[1] == 'n') break;
  }
  return 0; 
}

