#include <stdio.h>
#define MAX 2000000001

int S[MAX],H = 1;

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}
void maxHeapify(int i){
  int l,r,largest,tmp;
  l = left(i);
  r = right(i);
  if(l <= H && S[l] > S[i]) largest = l;
  else largest = i;
  if(r <= H && S[r] > S[largest]) largest = r;
  if(largest != i){
    tmp = S[i];
    S[i] = S[largest];
    S[largest] = tmp;
    maxHeapify(largest);
  }
}


void heapIncreaseKey(int i,int key){
  int tmp;
  if(key < S[i]) return;
  S[i] = key;
  while(i > 1 && S[parent(i)] < S[i]){
    tmp = S[i];
    S[i] = S[parent(i)];
    S[parent(i)] = tmp;
    i = parent(i);
  }
}

void insert(int k){
  H++;
  S[H] = -1;
  heapIncreaseKey(H,k);
}

void extract(void){
  int max;
  max = S[1];
  S[1] = S[H];
  H--;
  maxHeapify(1);
  printf("%d\n",max);
}

int main()
{
  int i,n,k;
  char buf[10];
  while(1){
    scanf("%s",buf);
    if(buf[0] == 'i'){
      scanf("%d",&k);
      insert(k);
    }
    else if(buf[0] == 'e' && buf[1] == 'x') extract();
    else if(buf[0] == 'e' && buf[1] == 'n') break;
  }
  return 0;
}

