#include<stdio.h>

#define N 2000000
#define INFTY 2000000010

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

int size,A[N];

int main(){
  int key;
  char com[10];
   
  while(1){
    scanf("%s",com);
    if(com[0]=='e' && com[1]=='n'){
      break;
    }else if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }else if(com[0]=='e' && com[1]=='x'){
      printf("%d\n",extractMax());
    }
  }
   
  return 0;
}

void maxHeapify(int i){
        
  int l,r,largest,temp;
     
  l = left(i);
  r = right(i);
    
  if (l <= size && A[l] > A[i]) largest = l;
  else largest = i;
    
  if(r <= size && A[r] > A[largest]) largest = r;

  if(largest != i){
    temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    maxHeapify(largest);
  }

}

int extractMax(){
  int maxkey;
  if(size<1) return -INFTY;
  maxkey=A[1];
  A[1]=A[size];
  size=size-1;

  maxHeapify(1);
  return maxkey;
}

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

void insert(int key){
  size=size+1;
  A[size]=-INFTY;
  increaseKey(size,key);
}

int parent(int i){
  int pid;
  pid=i/2;

  return pid;
}

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

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

