#include<stdio.h>
#include<string.h>

#define MAX 2000000
#define INFTY 1073000000

int A[MAX+1],H=0;


int parent(int);
int left(int);
int right(int);
void maxHeapify(int);
void insert(int);
void increaseKey(int,int);
int extractMax(void);
void swap(int,int);

 int parent(int i){
  return i/2;
}
 
int left(int i){
  return 2*i;
}
 
int right(int i){
  return 2*i+1;
}
 
int main(){
  int key;
  char c[10];
  
  while(1){
    scanf("%s",c);
    
    if(c[0] =='e' && c[1] == 'n') break;

    if(c[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }
    else{
      printf("%d\n",extract());
    }
  }
  
  return 0;
}
 
void maxHeapify(int i){
  int r,lef,largest;
  
  lef = left(i);
  r = right(i);
 
  if(lef <= H && A[lef] > A[i]) largest = lef;
  else largest = i;

  if(r <= H && A[r] > A[largest]) largest = r;
 
  if(largest != i){
    swap(i,largest);
    maxHeapify(largest);
  }
}
 

void swap(int i, int largest){
  int tmp;
  tmp = A[i];
  A[i] = A[largest];
  A[largest] = tmp;
}
 
 
void insert(int key){
  H++;
  A[H]=-INFTY;
  increaseKey(H,key);
}
 
int extract(void){
  int max;

  if(H < 1) return -INFTY;

  max = A[1];
  A[1] = A[H--];
  maxHeapify(1);
   
  return max;
}

void increaseKey(int i,int key){
  if(key < A[i]) return;
  A[i] = key;
  
  while(i > 1 && A[parent(i)] < A[i]){
    swap(parent(i),i);
    i = parent(i);
  }
}

