#include<stdio.h>
#define N 2000000
#define I 1000000

int h,a[N+1];

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

  if(l<=h && a[l]>a[i])max=l;
  else max=i;
  if(r<=h && a[r]>a[max])max=r;

  if(max != i){
    t=a[i];
    a[i]=a[max];
    a[max]=t;
    maxheap(max);
  }
}

int extract(){
  int max;
  if(h<1)return -I;
  max=a[1];
  a[1]=a[h--];
  maxheap(1);
  return max;
}

void increasekey(int i, int key){
  int t;
  if(key<a[i])return;
  a[i]=key;
  while(i>1 && a[i/2]<a[i]){
 t=a[i];
    a[i]=a[i/2];
    a[i/2]=t;
    i=i/2;
  }
}

void insert(int key){
  h++;
  a[h]=-I;
  increasekey(h,key);
}

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

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

  return 0;
}

