#include <stdio.h>

int h=0,aa[2000000000];

void mh(int i){
  int l,r,big,t;

  l = i*2;
  r = i*2 + 1;

  if(l<=h && aa[l]>aa[i])big = l;
  else big = i;
  if(r<=h && aa[r] > aa[big])big = r;

  if(big!=i){
    t=aa[i];
    aa[i]=aa[big];
    aa[big]=t;
    mh(big);
  }
}

/*
void bmh(void){
  int i;
  for(i=h/2;1<=i;i--){
    mh(i);
  }
}
*/

void in(int key){
  int t,tt;
  h++;
  tt=h;
  aa[h] = key;
  while(1<tt && aa[tt/2]<aa[tt]){
    t=aa[tt];
    aa[tt] = aa[tt/2];
    aa[tt/2] = t;
    tt = tt/2;
  }   
}

void ex(void){
  printf("%d\n",aa[1]);
  aa[1] = aa[h];
  h--;
  mh(1);
}
  

int main(){
  int i,key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[2]=='d')break;

    if(com[0]=='i'){
      scanf("%d",&key);
      in(key);
    }
    else if(com[0]=='e'){
      ex();
    }
  }

  return 0;
}

