#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX 5000000
#define N -1
 
int key[MAX],n,count = 0;
 
int parent(int p){
  return p/2;
}
 
int right(int p){
  return 2*p+1;
}
 
int left(int p){
  return 2*p;
}
 
void maxHeapify(int p){
  int l,r,largest=N,temp;
  l = left(p);
  r = right(p);
 
  if(l <= count && key[l]>key[p]) largest = l;
  else largest = p;
  if(r<= count && key[r]>key[largest]) largest = r;
  if(largest != p){
    temp = key[p];
    key[p] = key[largest];
    key[largest] = temp;
    maxHeapify(largest);
  }
 
}
 
void buildMaxHeap(){
  int i;
  for(i = count/2; i > 0; i--){
    maxHeapify(i);
  }
}
 
void heapIncreaseKey(int p,int in){
  int temp,i;
 
  if(in < key[p]){
    exit(1);
  }
 
  key[p] = in;
 
  while(p > 1 && key[parent(p)] < key[p]){
    temp = key[p];
    key[p] = key[parent(p)];
    key[parent(p)] = temp;
 
    p = parent(p);
  } 
}
 
void maxHeapInsert(int in){
  int i;
  count++;
  key[count] = N;
  heapIncreaseKey(count,in);
}
 
 
int heapExtractMax(){
  int max;
  if(count < 1){
    exit(1);
  }
 
  max = key[1];
  key[1] = key[count];
  count--;
 
  maxHeapify(1);
 
  return max;
}
 
 
int main(){
  int i,v,max;
  char com[20];
 
 
  for ( i = 0; i < MAX; i++ ){
    key[i] = N;
  }
 
  while(strcmp(com,"end") != 0){
    scanf("%s",com);
    if(com[0] == 'i'){
      scanf("%d" ,&v);
      maxHeapInsert(v);
    }
    else if(com[1] == 'x'){
      max = heapExtractMax();
      printf("%d\n",max);
    }
  }
  return 0;
}