#include <stdio.h>

#define I 10000000

int h = 0, a[2000000000];

void makekey(int i, int k)
{
  int x;
  
  if (k < a[i])
    return;
  a[i] = k;
  while (i > 1 && a[i/2] < a[i]){
    x = a[i];
    a[i] = a[i/2];
    a[i/2] = x;
    i = i/2;
  }
}

void insert(int k)
{ 
  h++;
  a[h] = -I;
  makekey(h,k);
}

void maxheapify(int i)
{
  int l, r, largest, x;

  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){
    x = a[i];
    a[i] = a[largest];
    a[largest] = x;
    maxheapify(largest);
  }
}

int extract()
{
  int max;

  if (h < 1)
    return -I;
  max = a[1];
  a[1] = a[h--];
  maxheapify(1);
  return max;
}

int main()
{
  int k;
  char c[8];

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

  return 0;
}

