#include<stdio.h>
#define M 2000000000
#define INF (1 << 21)

void maxHeapify(int);
void insert(int);
void increase(int, int);
int extract(void);

int A[M], H;
int left(i)
{
  return 2 * i;
}
int right(i)
{
  return 2 * i + 1;
}
void maxHeapify(int i)
{
  int l, r, largest;
  int tmp;
  l = left(i);
  r = right(i);
  if(l <= H && A[l] > A[i])
    {
      largest = l;
    }
  else
    {
      largest = i;
    }
  if(r <= H && A[r] > A[largest])
    {
      largest = r;
    }
  if(largest != i)
    {
      tmp = A[i];
      A[i] = A[largest];
      A[largest] = tmp;
      maxHeapify(largest);
    }
}

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

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

int extract()
{
  int m;
  if(H < 1)
    {
      return -INF;
    }
  m = A[1];
  A[1] = A[H];
  H--;
  maxHeapify(1);
  return m;
}

int main()
{
  int n;
  A[H] = -INF;
  char ch[10];
  while(1)
    {
      scanf("%s", ch);
      if(ch[0] == 'e' && ch[1] == 'n')
	{
	  break;
	}
      if(ch[0] == 'i')
	{
	  scanf("%d", &n);
	  insert(n);
	}
      else
	{
	  printf("%d\n", extract());
	}
    }
  return 0;
}

