#include<stdio.h>
#define MAX 1000000
#define INFTY (1<<21)

int n,A[MAX+1];

void maxHeapify(int i)
{
  int left,right,largest,a;
  left=2*i;
  right=2*i+1;
  if(left<=n && A[left]>A[i])
    largest=left;
  else
    largest=i;
  if(right<=n && A[right]>A[largest])
    largest=right;
  if(largest!=i)
    {
      a=A[i];
      A[i]=A[largest];
      A[largest]=a;
      maxHeapify(largest);
    }
}

int extract()
{
  int x;
  if(n<1)
    return -INFTY;
  x=A[1];
  A[1]=A[n--];
  maxHeapify(1);
  return x;
}

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

void insert(int key)
{
  n++;
  A[n]=-INFTY;
  increaseKey(n,key);
}

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

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