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

void insert(int);
int ext(void);
void increaseKey(int);
void maxHeapify(int);

int h,A[N],largest;

int main(){
  int a,i;
  char com[10],in[]="insert",end[]="end";

  
  h=0;
  while(1){
    scanf(" %s",com);
    if(strcmp(com,in)==0){
      //if(com[0] == 'i'){
      scanf(" %d",&a);
      insert(a);
    }
    else if(strcmp(com,end)==0){
      break;
    }
    else{
      printf("%d\n",ext());
    }
    //for(i=1;i<5;i++) printf("[%d,%d]",i,A[i]);
  }
  
  return 0;
}

void insert(int a){
  h++;
  A[h] = -1000000;
  increaseKey(a);
}

void increaseKey(int a){
  int i,put;
  /*printf("[3 %d]",a);*/
  i=h;
  if(a < A[i]) return;
  A[i] = a;
  while(i > 1 && A[i / 2] < A[i]){
    put = A[i];
    A[i] = A[i / 2];
    A[i / 2] = put;
    i = i / 2;
  }
}

int ext(void){
  int max,i;
  if(h < 1) return -1000000;
  max = A[1];
  A[1] = A[h--];
  maxHeapify(1);
  return max;
}

void maxHeapify(int i){
  int put;
  
  if(2*i <= h && A[2*i] > A[i]) largest = 2*i;
  else largest = i;
  if(2*i+1 <= h && A[2*i+1] > A[largest]) largest = 2*i+1;

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

