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

int heap_size = 0;

void maxHeap(int*,int);
void heapIncrease(int*,int,int);
void maxHeapInsert(int*,int);
int heapExtractMax(int*);

int main() {
  char com[10];
  int heap[2000000];
  int arg;
  while (1) {
    scanf("%s", com);
    if (com[0] == 'i') {
      scanf("%d", &arg);
      maxHeapInsert(heap, arg);
    } else if (com[1] == 'x') {
      printf("%d\n", heapExtractMax(heap));
    } else {
      break;
    }
  }
  return 0;
}
  
  void maxHeap(int* array, int i) {
    int a,b,max;
    int work;
    a=i*2;
    b=i*2+1;
    if (a<=heap_size&&array[a]>array[i]){
      max=a;
    }
    else{
      max=i;
    }
    if(b<= heap_size&&array[b]>array[max]){
      max=b;
    }
    if(max!=i){
      work=array[i];
      array[i]=array[max];
      array[max]=work;
      maxHeap(array,max);
    }
  }
  void heapIncreaseKey(int* array, int i, int key) {
    int work;
    array[i]=key;
    while(i>1&&array[i/2]<array[i]){
      work=array[i];
      array[i]=array[i/2];
      array[i/2]=work;
      i=i/2;
    }
  }
  void maxHeapInsert(int* array, int key) {
    heap_size++;
    array[heap_size]=-1;
    heapIncreaseKey(array,heap_size,key);
  }
  int heapExtractMax(int* array) {
    long max;
    max=array[1];
    array[1]=array[heap_size];
    heap_size--;
    maxHeap(array,1);
    return max;
  }