#include <stdio.h>
#define MAX 2000000

void maxHeapify(int);
void swap(int *a,int *b);
int extract(void);
void increaseKey(int,int);
void insert(int);


int H,A[MAX+1];

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{
      printf("%d\n",extract());
    }
  }

  return 0;
}
      
       
void maxHeapify(int i){
  int left,right,max;
  left=2*i;
  right=2*i+1;

  
  if(left<=H && A[left]>A[i]){
    max=left;
  }else max=i;

  if(right<=H && A[right]>A[max]){
    max=right;
  }

  if(max!=i){
    swap(&A[i],&A[max]);
    maxHeapify(max);
  }
}


void swap(int *a,int *b){
  int temp;

  temp=*a;
  *a=*b;
  *b=temp;
}

void insert(int key){
  H++;
  A[H]=key;
  increaseKey(H,key);
}

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

int extract(){
  int max;
  max=A[1];
  A[1]=A[H];
  H--;
  return max;
}