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

#define N 2000000
 
void maxHeapify(int );
void insert(int );
int extractMax();
void fuelKey(int, int);

int cnt,A[N+1];

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

 while(1)
 {
  scanf("%s",order);
  if(strcmp(order,"end") == 0) break;

  if(order[0] == 'i')
  {
   scanf("%d",&k);
   insert(k);
  }
  else  printf("%d\n",extractMax());
 }
  
 return 0;
}

void insert(int n)
{
  cnt++;
  A[cnt] = -N;
  fuelKey(cnt,n);
}

void fuelKey(int m, int n)
{
  int swap;
  if(n < A[m]) return;
   A[m] = n;
   while(m > 1 && A[m / 2] < A[m])
   {
    swap = A[m];
    A[m] = A[m/2];
    A[m/2] = swap;
    m = m / 2;
   }
}

int extractMax()
{
 int max;
 
 if(cnt < 1) return -N;

 max = A[1];
 A[1] = A[cnt--];
 maxHeapify(1); 
 return max;
}
 
 
void maxHeapify(int i)
{
  int l = 2*i, r = 2*i + 1;
  int largest,swap;
 
  if(l <= cnt && A[l] > A[i])
    largest = l;
  else
    largest = i;
 
  if(r <= cnt && A[r] > A[largest])
    largest = r;
 
  if(largest != i)
    {
      swap = A[i];
      A[i] = A[largest];
      A[largest] = swap;
      maxHeapify(largest);
    }
   
}
 
