#include<stdio.h>
#include<string.h>
#define INF 1000000000

void insert(int *,int);
void maxHeapfy(int *,int);
int extract(int *);
void increase(int *,int ,int);

int size;//外部変数だから0に初期化される

int main(){
  int i, x,A[2000000];
  char com[20];
 
  for ( i = 0; ; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(A,x);
    }else if(com[0]=='e'&&com[1]=='x'){
      printf("%d\n",extract(A));
    }else{
      break;
    }
  }
  return 0;
}



void maxHeapify(int *A,int i){
  int l,r,largest,a;
  l=2*i;
  r=2*i+1;
  
  if(l<=size&&A[l]>A[i]){
    largest=l;
  }else{
    largest=i;
  }

  if(r<=size&&A[r]>A[largest]){
    largest=r;
  }

  if(largest!=i){
    a=A[i];
    A[i]=A[largest];
    A[largest]=a;
    maxHeapify(A,largest);
  }
}



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

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


void insert(int *A,int key){
  size++;
  A[size]=-INF;
  increase(A,size,key);
}



