#include<stdio.h>
#include<string.h>
#define MAX 20000000

int H,A[MAX+1];


void maxheapify(int i)
{
  int left;
  int right;
  int change;
  int large;
  
  left = 2*i;
  right = 2*i+1;
  
  if( left <= H && A[left] > A[i] ){
    large = left;
  }
  else{
    large = i;
  }
  
  if( right <= H && A[right] > A[large] ){
    large = right;
  }
  
  if( large != i ){
    change = A[i];
    A[i] = A[large];
    A[large] = change;
    maxheapify(large);
  }
}


int ex()
{
  int max;
  if( H < 1 ) return -1000000000;
		
  max = A[1];
  A[1] = A[H--];
  maxheapify(1);
  return max;
}

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

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

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",ex());
    }
  }
  return 0;
}

