#include <stdio.h>
#include <limits.h>

int A[2000001], size = 0;

int extract(void);
void increaseKey(int, int);
void insert(int);
int extractMax(void);
void maxHeapify(int);

int main()
{
  int k, max;
  char input[10];

  while(1)
    {
      scanf("%s",input);

      if(input[0] == 'e' && input[1] == 'n')break;
      if(input[0] == 'i')
	{
	  scanf("%d",&k);
	  insert(k);
	}
      else
	{
	  max = extractMax();
	  printf("%d\n",max);
	}
    }

  
  return 0;
}

int extract(void)
{
  int maxv;
  if(size < 1)return -INT_MAX;
  maxv = A[1];
  A[1] = A[size--];
  maxHeapify(1);
  return maxv;
}

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

void insert(int k)
{
  int i;
  
  size++;
  A[size] = -INT_MAX;
  increaseKey(size, k);
}

int extractMax(void)
{
  int max;
  max = A[1];
  A[1] = A[size];
  size--;
  maxHeapify(1);
  return max;
}

void maxHeapify(int i)
{
  int l, r, largest, temp;

  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)
    {
      temp = A[i];
      A[i] = A[largest];
      A[largest] = temp;

      maxHeapify(largest);
    }
}

