#include<stdio.h>
#include<stdlib.h>
#define MAX 200000000

void insert(int);
int extractMax(void);
void heapIncreaseKey(int,int);
void maxHeapify(int);
int parent(int);
int left(int);
int right(int);

int S[MAX+1];
int cnt=0;

int main()
{
  int i = 0,num,ret;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[2] == 'd')break;

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

void insert(int key)
{
  cnt++;
  S[cnt] = -1;
  heapIncreaseKey(cnt,key);
}

void heapIncreaseKey(int i, int key)
{
  int temp;
  
  S[i] = key;
  
  while(i > 1 && S[parent(i)] < S[i]){
    temp = S[i];
    S[i] = S[parent(i)];
    S[parent(i)] = temp;
    i = parent(i);
  }
}

int extractMax(void)
{
  int max;

  max = S[1];
  S[1] = S[cnt];
  cnt--;
  maxHeapify(1);

  return max;
}

void maxHeapify(int i)
{
  int l,r,largest,temp;

  l = left(i);
  r = right(i);

  if(l <= cnt && S[l] > S[i])
    largest = l;
  else
    largest = i;
  if(r <= cnt && S[r] > S[largest])
    largest = r;

  if(largest != i){
    temp = S[i];
    S[i] = S[largest];
    S[largest] = temp;
    maxHeapify(largest);
  } 
}

int parent(int i)
{
  return i/2;
}

int left(int i)
{
  return 2 * i;
}

int right(int i)
{
  return 2 * i + 1;
}

