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

#define INFTY (1 << 30)

void maxHeapify(int);
int Extract();
void IncreseKey(int,int);
void Insert(int);

int n, A[2000001];

int main(){
  int key;
  char str[10];

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

    if(str[0] == 'e' && str[1] == 'n') break;
    else if(str[0] == 'i'){
      scanf("%d",&key);
      Insert(key);
    }
    else printf("%d\n",Extract());
  }

  return 0;
}

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

  if(left <= n && A[left] > A [x]) largest = left;
  else largest = x;

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

  if(largest != x){
    tmp = A[x];
    A[x] = A[largest];
    A[largest] = tmp;

    maxHeapify(largest);
  }
}

int Extract(){
  int max;
  if(n < 1) return -INFTY;
  max = A[1];
  A[1] = A[n--];
  maxHeapify(1);
  return max;
}

void IncreseKey(int x, int key){
  int tmp;
  if(key < A[x]) return;
  A[x] = key;
  while(x > 1 && A[x / 2] < A[x]){
    tmp = A[x];
    A[x] = A[x / 2];
    A[x / 2] = tmp;
    x = x / 2;
  }
}

void Insert(int x){
  n++;
  A[n] = -INFTY;
  IncreseKey(n, x);
}

