#include <stdio.h>
#include <string.h>
#include <limits.h>

int A[20000003], size = 0;
void insert(int *, int);
void increase(int *, int, int);
int extract(int *);
int parent(int);
void maxheapify(int *, int);
int left(int *, int);
int right(int *, int);

main() {
  int n, i;
  char com[20];

  while(1) {
    scanf("%s", com);
    if(com[0] == 'i') {
      scanf("%d", &n);
      insert(A, n);
    }
    else if(com[0] == 'e' && strlen(com) > 5) {
      printf("%d\n", extract(A));
    }
    else {
      break;
    }
  }
  return 0;
}

void insert(int *A, int key) {
  size = size + 1;
  A[size] = INT_MIN;;
  increase(A, size, key);
}

void increase(int *A, int i, int key) {
  int tmp, p;
  if(key < A[i]) {
    printf("error");
  }
  A[i] = key;
  while(i > 1 && A[parent(i)] < A[i]) {
    tmp = A[parent(i)];
    A[parent(i)] = A[i];
    A[i] = tmp;
    i = parent(i);
  }
}

int extract(int *A) {
  int max;
  if(size < 1) {
    printf("error");
    return 0;
  }
  max = A[1];
  A[1] = A[size];
  size = size - 1;
  maxheapify(A, 1);
  return max;
}

int parent(int i) {
  return i / 2;
}
int left(int *a, int i) {
    return 2 * i;
}
int right(int *a, int i) {
    return 2 * i + 1;
}

void maxheapify(int *a, int i) {
  int largest, l, r, tmp;
  l = left(a, i);
  r = right(a, i);
  if(l <= size && a[l] > a[i]) {
    largest = l;
  }
  else {
    largest = i;
  }
  if(r <= size && a[r] > a[largest]) {
    largest = r;
  }
  if(largest != i) {
    tmp = a[i];
    a[i] = a[largest];
    a[largest] = tmp;
    maxheapify(a, largest);
  }
}