#include <stdio.h>
#define MAX 2000005

int heap[MAX], heapsize=0;

int heapExtractMax();
void heapIncraseKey(int,int);
void MaxheapInsert(int);
void maxHeapify(int);

int main(){
  int a, key;
  char command[10];

  while(1){
    scanf("%s",command);
    switch(command[0]){
      case 'i':
	scanf("%d",&key);
	MaxheapInsert(key);
	break;
      case 'e':
	if(command[1] == 'x') printf("%d\n",heapExtractMax());
	else return 0;
	break;
    }
  }
}

int heapExtractMax(){
  int max=heap[1];
  heap[1] = heap[heapsize];
  heapsize--;
  maxHeapify(1);
  return max;
}

void heapIncreaseKey(int a, int key){
  int temp;
  heap[a] = key;
  while(a > 1 && heap[a/2] < heap[a]){
    temp = heap[a];
    heap[a] = heap[a/2];
    heap[a/2] = temp;
    a = a/2;
  }
}

void MaxheapInsert(int key){
  heapsize++;
  heapIncreaseKey(heapsize,key);
}

void maxHeapify(int a){
  int l=2*a, r=2*a+1, largest, temp;

  if(l <= heapsize && heap[l] > heap[a]) largest = l;
  else largest = a;
  if(r <= heapsize && heap[r] > heap[largest]) largest = r;
  if(largest != a){
    temp = heap[a];
    heap[a] = heap[largest];
    heap[largest] = temp;
    maxHeapify(largest);
  }
}

