#include<stdio.h>

#define MAX 2000000
#define INF 99999999

int H,A[MAX + 1];

void max(int i){
  int l,r,big;
  int swap;
  l = i * 2;
  r = l + 1;

  if(l <= H && A[l] > A[i]) big = l;
  else big = i;
  if(r <= H && A[r] > A[big]) big = r;

  if(big != i){
    swap = A[i];
    A[i] = A[big];
    A[big] = swap;
    max(big);
  }
}

int extract() {
  int maxv;
  if(H < 1) return -INF;
  maxv = A[1];
  A[1] = A[H--];
  max(1);
  return maxv;
}

void increas(int i, int key){
  int swap;
  if(key < A[i]) return;
  A[i] = key;
  while(i > 1 && A[i / 2] < A[i]){
    swap = A[i];
    A[i] = A[i / 2];
    A[i / 2] = swap;
    i = i / 2;
  }
}

void insert(int key){
  H++;
  A[H] = -INF;
  increas(H,key);
}


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

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

