#include <stdio.h>
#define MAX 2000001
  
int h = 0;

void MaxHeapify(int *a, int i){
  int left, right, large, change;
  
  if(i*2<=h){
    left=i * 2;
  }
  else left = i;
  if(i*2+1<=h){
    right=i*2+1;
  }
  else right = i;
  
  
  if(left < h + 1 && a[left] > a[i]) large = left;
  else large = i;
  if(right < h + 1 && a[right] > a[large]) large = right;
    
  if(large != i){
    change = a[i];
    a[i] = a[large];
    a[large] = change;
    MaxHeapify(a, large);
  }
}

void Insert(int *a, int key){
  int i, change;
  
  h++;
  i=h;
  a[i]=key;
  while(i>1 && a[i/2]<a[i]){
    change=a[i];
    a[i]=a[i/2];
    a[i/2]=change;
    i=i/2;
  }
}
  
void ExtractMax(int *a){
  int m;
  
  m=a[1];
  a[1]=a[h];
  h--;
  MaxHeapify(a, 1);
  
  printf("%d\n",m);
}

int main(){
  int a[MAX], key;
  int i=0, j;
  char str[8];
  
  while( 1 ){
    scanf("%s",str);
    if(str[2] == 'd') break;
    else if(str[0] == 'i'){
      scanf("%d", &key);
      Insert(a, key);
    }
    else ExtractMax(a);
  }
  return 0;
}