#include <stdio.h>
#include <limits.h>
#define MAX 2000000

/* Prototype Declaration */
void insert(int);
void heapIncreaseKey(int, int);
int extractMax(void);
void maxHeapify(int);

/* Global Variables */
long A[MAX + 1];
int H = 0;

int main() {
  int k, s;
  char command[8];

  while ( 1 ) {
    scanf("%s", command);

    if ( command[0] == 'i' ) {
      scanf("%d", &k);
      insert(k);
    }else if ( command[0] == 'e' && command[1] == 'x' ) {
      s = extractMax();
      if ( s != -1 ) printf("%d\n", s);
    }else if ( command[0] == 'e' && command[1] == 'n' ) break;
  }

  return 0;
}

/* Insert Key to Priority Queue */
void insert(int keydata) {
  H++;
  A[H] = LONG_MIN; // -2147483647
  heapIncreaseKey(H, keydata);
}

void heapIncreaseKey(int i, int keydata) {
  long tmp;
  if ( keydata < A[i] ) return;
  A[i] = keydata;

  while ( i > 1 && A[i / 2] < A[i]) {
    tmp = A[i];
    A[i] = A[i / 2];
    A[i / 2] = tmp;
    i = i / 2;
  }
}

/* Extract Max Key from Priority Queue */
int extractMax() {
  long max;

  if ( H < 1 ) return -1;

  max = A[1];
  A[1] = A[H];
  H--;

  maxHeapify(1);

  return max;
}

void maxHeapify(int i) {
  int left, right, largest;
  long tmp;
  left = 2 * i;
  right = left + 1;

  if ( left <= H && A[left] > A[i] )
    largest = left;
  else
    largest = i;

  if ( right <= H && A[right] > A[largest] )
    largest = right;

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