#include <stdio.h>
#include <string.h>
#define N 2000000

int n=0;
int A[N+1];

void maxheapify(int i){
  int l,r,largest,cmp;

  l = 2*i;
  r = 2*i+1;

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

  if(r <= n && A[r] > A[largest]) largest = r;

  if(largest != i) {
     cmp = A[i];
     A[i] = A[largest];
     A[largest] = cmp;
     maxheapify(largest);
  }
}
void  buildMaxHeap(){
  int i;

  for(i=n/2;i>0;--i) maxheapify(i);
}

int extractMax(){
  int max;

  max = A[1];
  
  A[1] = A[n];
  n--;

  maxheapify(1);

  return max;
  
}

void Increasekey(int i,int num){
  int cmp;
  if(num<A[i])printf("error");

  A[n] = num;

  while(i > 1 && A[i/2] < A[i]){
    cmp = A[i];
    A[i] = A[i/2];
    A[i/2] = cmp;
    i = i/2;
  }
  
}
void Heap_insert(int num){
  int i;
  
  n++;
  A[n] = -1;
  Increasekey(n,num);
}




int main(){
  int i,num;
  char order[10];
 
 
  while(1){
    scanf("%s",order);

    if(strcmp("end",order) == 0)break ;

    if(order[0]=='e')printf("%d\n",extractMax());

    else if(order[0] == 'i') {
      scanf("%d",&num);
      Heap_insert(num);
    }
  }

  return 0;
}

