#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 2000000
#define NIL (-1)

int parent(int );
int left(int );
int right(int );
void buildMaxHeap(int []);
void maxHeapify(int [], int);
void maxHeapInsert(int [], int );
void heapIncreaseKey(int [], int, int);
int heapExtractMax(int []);

int n;

int main(void){
  
  int key;
  int Tree[MAX];
  char com[10];
  
  while(1){ 
    scanf("%s",com);
    if(com[0] == 'i'){
      scanf("%d",&key);
      maxHeapInsert(Tree, key);
    }
    
    else if(com[0] == 'e'){
      if(strlen(com) == 7)
	printf("%d\n",heapExtractMax(Tree));
      else 
	break;
    }
  }
  
  return 0;
}

int parent(int i){
  return i / 2;
}

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

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

void buildMaxHeap(int Tree[]){
  int i;

  for(i = n/2;i >= 1;i--)
    maxHeapify(Tree, i);
}

void maxHeapify(int Tree[], int i){
  int l = left(i);
  int r = right(i);
  int largest;
  int tmp;

  if(l <= n && Tree[l] > Tree[i])
    largest = l;

  else
    largest = i;

  if(r <= n && Tree[r] > Tree[largest])
    largest = r;

  if(largest != i){
    tmp = Tree[largest];
    Tree[largest] = Tree[i];
    Tree[i] = tmp;
    maxHeapify(Tree, largest);
  }
}

void maxHeapInsert(int Tree[], int key){
  n = n + 1;
  Tree[n] = NIL;
  heapIncreaseKey(Tree, n, key);
}

void heapIncreaseKey(int Tree[], int i, int key){

  int tmp;

  if(key < Tree[i])
    exit(1);

  Tree[i] = key;

  while(i > 1 && Tree[parent(i)] < Tree[i]){
    tmp = Tree[parent(i)];
    Tree[parent(i)] = Tree[i];
    Tree[i] = tmp;
    i = parent(i);
  }
}


int heapExtractMax(int Tree[]){
  int max;
  
  if(n < 1)
    exit(2);
  
  max = Tree[1];
  Tree[1] = Tree[n];
  n = n - 1;
  maxHeapify(Tree, 1);
  return max;
}