#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define INF 2000000001
int A[2000000], heap_size=0;
void maxHeapify(int i){
  int l, r, max, cp;
  l = 2*i;
  r = 2*i+1;
  if(l <= heap_size && A[l] > A[i])
    max = l;
  else max = i;
  if(r <= heap_size && A[r] > A[max])
    max = r;
  if(max != i){
    cp = A[i];
    A[i] = A[max];
    A[max] = cp;
    maxHeapify(max);
  }
  return;
}
int extract(){
  int max;
  if(heap_size < 1) return;
  max = A[1];
  A[1] = A[heap_size];
  heap_size--;
  maxHeapify(1);
  return max;
}
void heapIncreaseKey(int i, int key){
  int ch;
  //if(key < A[i]) return;
  A[i] = key;
  while(i > 1 && A[i/2] < A[i]){
    ch = A[i];
    A[i] = A[i/2];
    A[i/2] = ch;
    i = i/2;
  }
}
void insert(int key){
  heap_size = heap_size+1;
  A[heap_size] = INF;
  heapIncreaseKey(heap_size, key);
}
int main(){
  int key, max;
  char s[10];
  while(1){
    scanf("%s",s);
    if(s[0] == 'i'){
      scanf("%d",&key);
      heap_size++;
      insert(key);
    }
    else if(s[1] == 'x'){
      max = extract();
      printf("%d\n",max);
    }
    else if(s[0] == 'e')
      break;
  }
  return 0;
}