#include<stdio.h>
#include<stdlib.h>
#define N 2000000
int n=1,h=1;
int parent(int i){
  return i/2;

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

}

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

}

void maxHeapify(int* A,int i){
  int l = left(i),r = right(i),largest,tmp;;
  if(l<=n && A[l]>A[i])largest = l;
  else largest = i;
  if(r<=n&&A[r]>A[largest])largest=r;
  if(largest != i){
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(A,largest);
  }

}
void buildMaxHeap(int* A){
  int i;
  for(i=n/2;i>=1;i--){
    maxHeapify(A,i);
  }
  
}


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

void maxHeapInsert(int* A,int key){
  n++;
  A[n]=-500001;
  heapIncreaseKey(A,n,key);
}


int heapExtractMax(int* A){
  int max;

  if (n < 1)return ;
  max=A[1];
  A[1]=A[n];
  n--;
  maxHeapify(A,1);
  return max;
}



int main(){
  int heap[N];
  int i;
  char c[8];

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