#include <stdio.h>
#include <string.h>
    
int A[2000001];
int heap_size;
void insert(int key){ 
  heap_size++;
  A[heap_size] = -1;
  hpIK(key);
}
  
void hpIK(int key){  
  int i = heap_size, tmp; 
  if(key < A[i]){
    return;
  }
  A[i] = key;
  while(i > 1 && A[parentNode(i)] < A[i]){
    tmp = A[parentNode(i)];
    A[parentNode(i)] = A[i];
    A[i] = tmp;
    i = parentNode(i);
  }  
}
  
int hpEM(void){
  int max;
  if(heap_size < 1) return;
  max = A[1];
  A[1] = A[heap_size];
  heap_size--;
  maxHp(1);
  return max;  
}
void maxHp(int i){
  int l = leftChild(i);
  int r = rightChild(i);
  int largest, tmp;       
  if(l <= heap_size && A[l] > A[i]){
    largest = l;    
  }else{
    largest = i;
  }
  if(r <= heap_size && A[r] > A[largest]){
    largest = r;    
  }
  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHp(largest);
  }
}
  
int parentNode(int i){
  return (int)i/2;
}
   
int leftChild(int i){
  return 2*i;
}
   
int rightChild(int i){
  return 2*i+1;
}

int main(){
  int i, key;
  char com[8];
  while(scanf("%s",com), strcmp(com,"end")){
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    if(com[0]=='e'){
      printf("%d\n",hpEM());
    }
  }
  return 0;
}