#include<stdio.h>
#define N 500000
#define M -200000

int A[N],n;

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

int heapExtractMax() {

  int max;

  max = A[1];
  A[1] = A[n];
  n--;
  maxHeapify(1); 
    return max;

}


void heapIncreaseKey(i,key) {

  int tmp;
  
  if(key < A[i]) 
    return; 
  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 Insert(int key) {

  n++;
  A[n] = -N;
  heapIncreaseKey(n,key);
}

int main(void) {
  
  int i;
  char c[7];

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