#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
 
#define SIZE 2000001
 
int a[SIZE];
int n=0;
 
int parent(int i){
  return i/2;
}
 
int left(int i){
  return 2*i;
}
 
int right(int i){
  return 2*i+1;
}
 

int heapExtractMax(){
  int max = a[1];
 
  a[1] = a[n];
  n = n - 1;
  maxHeapify(1);
 
  return max;
}
 
int main(){
  int i,key;
  char com[SIZE-1];
 
  for(i = 1; i <SIZE; i++){
    scanf("%s",com);
    if(com[0] == 'i'){
      scanf("%d",&key);
      maxHeapInsert(key);
    }else if(com[0] == 'e' && com[1] == 'x'){
      printf("%d\n",heapExtractMax());
    }else if(com[0] == 'e' && com[1] == 'n'){
      break;
    }
  }
 
  return 0;
}
void maxHeapify(int i){
  int l = left(i),r = right(i);
  int largest,tmp;
 
  if(l+1 < n && a[l] > a[i]){
    largest = l;
  }else{
    largest = i;
  }
 
  if(r+1 < n && a[r] > a[largest]){
    largest = r;
  }
 
  if(largest != i){
    tmp = a[i];
    a[i] = a[largest];
    a[largest] = tmp;
    maxHeapify(largest);
  }
}
 
void buildMaxHeap(){
  int i;
  for(i = n/2; i > 0; i--){
    maxHeapify(i);
  }
}
 
void heapIncreaseKey(int i,int key){
  int tmp;
 
  a[i] = key;
 
  while(i > 1 && a[parent(i)] < a[i]){
    tmp = a[i];
    a[i] = a[parent(i)];
    a[parent(i)] = tmp;
    i = parent(i);
  }
}
 
void maxHeapInsert(int key){
  n = n + 1;
  a[n] = INT_MIN;
  heapIncreaseKey(n, key);
}
 