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

void insert(int);
void heapIncreaseKey(int*, int, int);
int extract(void);
void maxHeapify(int *, int);

int A[2000001], H;

int main()
{
  char ope[10];
  int k;

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

      if(ope[0] == 'i')
	{
	  scanf("%d", &k);
	  insert(k);
	}
      else if(ope[0] == 'e' && ope[1] == 'x')printf("%d\n", extract());
      else break;
    }
  return 0;
}

void insert(int k)
{
  H++;
  heapIncreaseKey(A, H, k);
}

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

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

void maxHeapify(int A[], int i)
{
  int l, r, largest, swap;
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= H && A[l] > A[i])largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest])largest = r;

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

