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

#define MAX 2000000

int A[MAX];
int heap_size=0;

void maxHeapify(int i){
  int l,r,largest,tmp;
  l=2*i;
  r=l+1;
  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;
    maxHeapify(largest);
  }
}

void buildMaxHeap(){
  int i;
  for(i=(int)(heap_size/2);i>=1;i--){
    maxHeapify(i);
  }
}


void heapIncreaseKey(int i,int key){
  int tmp;
  A[i]=key;
  while(i>1 && A[i/2]<A[i]){
    tmp=A[i];
    A[i]=A[i/2];
    A[i/2]=tmp;
    i=i/2;
  }
}

void maxHeapInsert(int key){
  heap_size+=1;
  A[heap_size]=-1;
  heapIncreaseKey(heap_size,key);
}

int heapExtractMax(void){
  int max;
  max=A[1];
  A[1]=A[heap_size];
  heap_size-=1;
  maxHeapify(1);
  return max;
}


main(){
  char order[20];
  int x;

  while(1){
    scanf("%s",order);
    if(order[0]=='i') {
      scanf("%d",&x);
      maxHeapInsert(x);
    }
    else if(order[1]=='x') printf("%d\n",heapExtractMax());
    else if(order[2]=='d')break;
  }
  return 0;
}