#include<stdio.h>
#define MAX 2000000
#define INFTY 1073000000
void maxHeapify(int);
void insert(int);
void increaseKey(int,int);
int extractMax(void);
void swap(int,int);
int parent(int);
int left(int);
int right(int);
int A[MAX+1],H=0;

int main(){
  int key;
  char c[8];
  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",extractMax());
    }
  }
  return 0;
}

void maxHeapify(int i){
  int r,l,largest;
  l = left(i);
  r = right(i);

  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i){
    swap(i,largest);
    maxHeapify(largest);
  }
}

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

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);
}

 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);
   }
 }
 int extractMax(void){
   int max;
   if(H < 1) return -INFTY;
   max = A[1];
   A[1] = A[H];
   H--;
   maxHeapify(1);
   return max;
}

