#include <stdio.h>
#include <string.h>
#define MAX 2000000
#define INF 2100000000

int H,A[MAX+1];
void maxH(int i){
  int l,r,lst,cd;
  l = 2*i; r = 2*i+1;

  //左の子、自身、右の子で値が最大のノードを選ぶ。
  if(l <= H && A[l] > A[i]) lst = l;
  else lst = i;
  if(r <= H && A[r] > A[lst]) lst = r;

  if(lst != i){
    cd = A[i]; A[i] = A[lst]; A[lst] = cd;
    maxH(lst);
  }
}

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

void increkey(int h,int key){
  int cd;
  if(key < A[h]) return;
  A[h] = key;
  while(h>1 && A[h/2] < A[h]){
    cd = A[h/2]; A[h/2] = A[h]; A[h] = cd;
    h = h/2;
  }
}

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

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

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

