#include <stdio.h>
#define MAX 2000000

int h[MAX+1],size = 0;

void maxHeapify(int i){
  int l,r,largest,ex;
  
  l = 2*i;
  r = 2*i+1;

  if(l <= size && h[l] > h[i])largest = l;
  else largest = i;

  if(r <= size && h[r] > h[largest])largest = r;
  
  if(largest != i){
    ex = h[i];
    h[i] = h[largest];
    h[largest] = ex;
    maxHeapify(largest);
  }
}

void IncreaseKey(int i,int k){
  int ex;
  
  h[i] = k;
  while(i > 1 && h[i/2] < h[i]){
    ex = h[i];
    h[i] = h[i/2];
    h[i/2] = ex;
    
    i /= 2;
  }

}

void Insert(int key){
  size++;
  h[size] = -1;
  IncreaseKey(size,key);
}

void extractMax(){
  if(size < 1)return;
  
  printf("%d\n",h[1]);
  h[1] = h[size];
  size--;
  
  maxHeapify(1);
}

int main(){
  int i,k;
  char a[7];
  
  for(i = 0;i < MAX; i++){
  scanf("%s",a);

  if(a[0] == 'i'){
    scanf("%d",&k);
    if(k < 0 || k > 2000000000)return 0;
    Insert(k);
  }
  else if(a[1] == 'x')extractMax();
  else return 0;

}
}

