#include<stdio.h>
#include<string.h>

#define MAX 2000000
#define INFTY (1<<30)

int H;
int A[MAX+1];

void maxHeapify(int x);
void insert(int key);
int extract(void);




int main(void){
  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 x){
  int l,r;
  int max,temp = 0;
  
  l = 2*x;
  r = 2*x + 1;

  if(l <= H && A[x] < A[l]){
    max = l;
  } else {
    max = x;
  }
  
  if(r <= H && A[max] < A[r] ){
    max = r;
  }

  if(max != x){
    temp = A[x];        
    A[x] = A[max] ;
    A[max] = temp ;
    
    maxHeapify(max);
  }
  
}



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



int extract(void){
  int max;
    
  if(H < 1){
    return -INFTY;
  }
    
  max = A[1];
  A[1] = A[H--];
    
  maxHeapify(1);
    
  return max;
}


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

