#include <stdio.h>
#include <stdlib.h>

#define INF 100000000

void maxheapify(int);
void insert(int);
void increase(int,int);
int extract(void);

int H[2000005];
int n;

int main(){
  int i,x;
  char c[8];
  
  while(1){
    scanf("%s",c);
    
    if(c[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    }
    
    else if(c[0] == 'e' && c[1] == 'x'){
      printf("%d\n",extract());
    }
    
    else if(c[0] == 'e')break;
  }
  
  return 0;
}

void swap(int *x,int *y){
  int temp;

  temp = *x;
  x = y;
  *y = temp;
}
void maxheapify(int i){
  int l = 2*i;
  int r = 2*i + 1;
  int largest;
  int temp;
  
  if(l <= n && H[l] > H[i]){
    largest = l;
  }
  else largest = i;

  if(r <= n && H[r] > H[largest]){
    largest = r;
  }

  if(largest != i){
    temp = H[i];
    H[i] = H[largest];
    H[largest] = temp;
    
    maxheapify(largest);
  }
} 

void increase(int i,int key){
  int temp;
  
  if(key < H[i])return;
  
  H[i] = key;
  
  while(i > 1 && H[i/2] < H[i]){
    temp = H[i];
    H[i] = H[i/2];
    H[i/2] = temp;
    
    i = i/2;
  }
}

int extract(void){
  int max;
  
  if(n<1)return -1*INF;
  max = H[1];
  H[1] = H[n];
  n--;

  maxheapify(1);
  return max;
}

void insert(int key){
  n++;
  H[n] = -1*INF;
  increase(n,key);
}

