#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

#define MAX 2000000
#define INF 100000000

int H,h[MAX+1];

void maxheapify(int i){
  int l,r,largest,a;
  l=2*i;
  r=2*i+1;

  if(l<=H&&h[l]>h[i])largest=l;
  else largest=i;
  if(r<=H&&h[r]>h[largest])largest=r;

  if(largest!=i){
    a=h[i];
    h[i]=h[largest];
    h[largest]=a;
    maxheapify(largest);
  }
}

void extract(){
  printf("%d\n",h[1]);
  h[1]=h[H];
  H--;
  maxheapify(1);
}

void increasekey(int i,int key){
  int a;

  h[i]=key;
  while(i>1&&h[i/2]<h[i]){
    a=h[i];
    h[i]=h[i/2];
    h[i/2]=a;
    i=i/2;
  }
}

void insert(int key){
  H++;
  h[H]=-INF;
  increasekey(H,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 extract();
  }
  return 0;
}

