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

#define M 1000000

int heapsize = 1;
int H[M];

void maxHeapify(int i){
  int lk,rk,lar,temp;

  lk = i*2;
  rk = i*2 + 1;

  if((lk <= heapsize) && (H[lk] > H[i])) lar = lk;
  else lar = i;
  if((rk <= heapsize) && (H[rk] > H[lar])) lar = rk;

  if(lar != i){
    temp = H[i];
    H[i] = H[lar];
    H[lar] = temp;
    maxHeapify(lar);
  }
}

void increase(int i,int k){
  int temp;
  
  if(k < H[i]) return;

  H[i] = k;
  while(i > 1 && H[i/2] < H[i]){
    temp = H[i];
    H[i] = H[i/2];
    H[i/2] = temp;
    i = i/2;
  }
}

void insert(int k){
  heapsize = heapsize + 1;
  H[heapsize] = -1000000;
  increase(heapsize,k);
}

int extract(void){
  int max;
  
  if(heapsize < 1) return -1000000;

  max = H[1];

  H[1] = H[heapsize];
  heapsize--;
  maxHeapify(1);

  return max;
}

int main(){
  char word[9];
  int key;

  while(1){

    scanf("%s",word);
    
    if(strcmp(word,"insert") == 0){
      scanf("%d",&key);
      insert(key);
    }
    
    else if(strcmp(word,"extract") == 0){
      printf("%d\n",extract());
    }

    else if(strcmp(word,"end") == 0) break;
    
  }
  
  return 0;
}

