#include<stdio.h>
#include<limits.h>
#define MAX 2000001
 
int size=0;
int A[MAX];
 
void MaxHeapInsert(int);
void HeapIncreaseKey(int ,int);
void MaxHeapify(int);
int HeapExtractMax();
int Parent(int);
int Left(int);
int Right(int);
 
int main(){
 
  int n,i,tmp,x;
  char com[20];
 
  while(1){
    scanf("%s",com);
    if(com[0] == 'i'){
      scanf("%d",&x);
      MaxHeapInsert(x);
    }
    else if(com[0] == 'e' && com[1] == 'x'){
      printf("%d\n",HeapExtractMax());
    }
    else if(com[0] == 'e' && com[1] == 'n')
      break;
  }
   
 
  return 0;
}
 
void MaxHeapInsert(int key){
 
  size++;
  heap[size] = INT_MIN;
  heapIncreaseKey(size,key);
}
 
void HeapIncreaseKey(int i, int key){
 
  int tmp;
 
  if(key < heap[i])
    printf("error\n");
  heap[i] = key;
  while(i > 1 && heap[parent(i)] < heap[i]){
    tmp = heap[i];
    heap[i] = heap[parent(i)];
    heap[parent(i)] = tmp;
    i = parent(i);
  }
}
 
int HeapExtractMax(){
 
  int max;
 
  max = heap[1];
  heap[1] = heap[size];
  size--;
  MaxHeapify(1);
  return max;
}
 
int Parent(int i){
  return i / 2;
  }
 
int Left(int i){
    return 2 * i;
}
  
int Right(int i){
    return 2 * i + 1;
}
 
void maxHeapify(int i){
    int left,right,largest,tmp;
  
    left = Left(i);
    right = Right(i);
    if(left <= size && heap[left] > heap[i])
        largest = left;
    else
        largest = i;
    if(right <= size && heap[right] > heap[largest])
        largest = right;
    if(largest != i){
        tmp = heap[i];
        heap[i] = heap[largest];
        heap[largest] = tmp;
        MaxHeapify(largest);
    }
}