#include<stdio.h>
#include<string.h>
#define M 2000000
#define INFTY 1

int N,S[M+1];

int left(int i){return i*2;}
int right(int i){return i*2 +1;}

void maxHeapify(int i){
  int l,r,lmax,swap;
  l = left(i);
  r = right(i);
  if(l <= N&&S[l]>S[i])
  {
  lmax = l;
  }
  else lmax = i;

  if(r <= N&& S[r]>S[lmax])
  {
    lmax = r;
  }
  if(lmax != i)
  {
    swap = S[i];
    S[i] = S[lmax];
    S[lmax] = swap;
    maxHeapify(lmax);
  }
}

int Extract(){
  int maxvalue;
  if(N<1)return -INFTY;
  maxvalue = S[1];
  S[1] = S[N--];
  maxHeapify(1);
  return maxvalue;
}

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

void insert(int key){
  N++;
  S[N] = -INFTY;
  increKey(N,key);
}

int main(){
  int key;
  char com[10];
  while(1){
    scanf("%s", com);
    if(com[0] == 'e' && com[1] =='n'){
      break;
    }
    if(com[0]=='i'){
      scanf("%d", &key);
      insert(key);
    }
    else printf("%d\n", Extract());
  }
  return 0;
}