#include<stdio.h>
#define N 2000001
#define NIL 2000000001

int A[N];
int hs = 0;

void maxheap(int i){
  int le, ri, lar;
  int temp;
  le = 2*i;
  ri = 2*i+1;
  if(le <= hs && A[le] > A[i]) lar = le;
  else lar = i;
  if(ri <= hs && A[ri] > A[lar]) lar = ri;
  if(lar != i){
    temp = A[i];
    A[i] = A[lar];
    A[lar] = temp;
    maxheap(lar);
  }
}
void heapincrease(int i, int key){
  int temp;
  A[i] = key;
  while(i > 1 && A[i/2] < A[i]){
    temp = A[i];
    A[i] = A[i/2];
    A[i/2] = temp;
    i /= 2;
  }
}

void heapinsert(int key){
  hs++;
  A[hs] = NIL;
  heapincrease(hs, key);
}

int heapextract(void){
  int max;
  max = A[1];
  A[1] = A[hs];
  hs--;
  maxheap(1);
  return max;
}

int main(){
  int k;
  char word[20];
  while(1){
    scanf("%s", word);
    if(word[0] == 'i'){
      scanf("%d", &k);
      heapinsert(k);
    }
    if(word[0] == 'e' && word[1] == 'x') printf("%d\n", heapextract());
    if(word[0] == 'e' && word[1] == 'n') break;
  }
return 0;
}