#include<stdio.h>
#define N 1000000

int size,data[N+1];

void maxHeapify(int i)
{
  int l,r,large,tmp;

  l = 2*i;
  r = 2*i+1;
  if(l<=size && data[l]>data[i] )
    large = l;
  else
    large = i;

  if(r<=size && data[r]>data[large])
    large = r;
  if(large != i){
    tmp = data[i];
    data[i] = data[large];
    data[large] = tmp;
    maxHeapify(large);
  }
}

int extract()
{
  int maxv;

  if(size < 1)
    return;

  maxv = data[1];
  data[1] = data[size--];
  maxHeapify(1);

  return maxv;
}

void increaseKey(int i, int k)
{
  int tmp;

  if(k < data[i])
    return;

  data[i] = k;

  while(i>1 && data[i/2]<data[i] ){
    tmp = data[i];
    data[i] = data[i/2];
    data[i/2] = tmp;
    i = i/2;
  }
}

void insert(int k)
{
  size++;
  data[size] = -1000000001;
  increaseKey(size,k);
}

int main()
{
  int k,m;
  char A[20];

  while(1){
    scanf("%s",A);

    if(A[0] == 'i'){
      scanf("%d",&k);
      insert(k);
    }
    else if(strcmp(A,"extract") == 0 ){
      m = extract();
      printf("%d\n",m);
    }
    else break;
  }

  return 0;
}
