#include<stdio.h>

#define N 2000000

void maxHeapInsert(int);
int extractMax();

int H[N];
int heapSize;


int main()
{
  int n, i, key;
  char str[8];
  
  heapSize=0;
  for(i=0; i<N; i++)
    {
      scanf("%s", str);
      if(str[0]=='i')
	{
	  scanf("%d", &key);
	  maxHeapInsert(key);
	}
      else if(str[1]=='x')
	{
	  printf("%d\n", extractMax());
	}
      else
	break;
    }
  return 0;
}

int extractMax()
{
  int max = H[0];

  H[0]=H[heapSize-1];
  heapSize--;
  
  return max;
}
void maxHeapInsert(int key)
{
  int i, tmp;
  
  H[heapSize]=key;
  heapSize++;
  i=heapSize;

  if(i/2 >= 1)
    {
      while(H[i/2 -1] <= H[i-1])
	{
	  tmp = H[(i)/2 -1];
	  H[(i)/2 -1] = H[i-1];
	  H[i-1] = tmp;
	  if((i/=2) <= 1) break;
	}
    }
}