#include <stdio.h>
#include <stdlib.h>

int n = 0;
int tree[2000001];

void insert(int);
void heapincreasekey(int);
void swap(int,int);
void extract(void);
void maxheapfy(int);

int main(){
  int key;
  char function[10];

  while( 1 ){
    scanf("%s",function);
    
    if(function[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }

    if(function[0] == 'e' && function[1] == 'x')  extract();

    if(function[0] == 'e' && function[1] == 'n')  break;
  }

  return 0;
}


void insert(int key){

  n++;
  tree[n] = key;
  heapincreasekey(n);
}

void heapincreasekey(int i){
  
  int p;

  p = i/2;
  if(p >= 1 && tree[i] > tree[p]){
    swap(i,p);
    heapincreasekey(p);
  }
  else return;
}

void swap(int i,int p){
  int box;
  box = tree[i];
  tree[i]=tree[p];
  tree[p]=box;
}

void extract(void){
  printf("%d\n",tree[1]);
  tree[1] = tree[n];
  n--;

  maxheapfy(1);
}


void maxheapfy(int i){
  int l,r,larger;
  l = 2 * i;
  r = l + 1;

  if( l <= n && tree[l] > tree[i]) larger = l;
  else larger = i;
  if( r <= n && tree[r] > tree[larger]) larger = r;

  if(larger != i){
    swap(larger,i);
    maxheapfy(larger);
  }
  else return;
}