#include <stdio.h>
#include <string.h>
#define INF 100000000
#define N 2000001

int h,A[N];

void exchange(int i,int j)
{
  int temp;
  temp=A[i];
  A[i]=A[j];
  A[j]=temp;
}

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

void maxHeapify(int i){
  int l,r,largest;
  l=left(i);
  r=right(i);
  if(l<=h&&A[l]>A[i])
    largest=l;
  else
    largest=i;
  if(r<=h&&A[r]>A[largest])
    largest=r;

  if(largest!=i){
    exchange(i,largest);
    maxHeapify(largest);
  }
  
}


int extract(){
  int max;
  if(h<1)return -INF;
  max=A[1];
  A[1]=A[h--];
  maxHeapify(1);
  return max;
}

void increaseKey(int i,int key){
  if(key<A[i])return;
  A[i]=key;
  while(i>1&&A[i/2]<A[i]){
    exchange(i,i/2);
    i/=2;
  }
}

void insert(int key){
  h++;
  A[h]=-INF;
  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;
}








