#include<stdio.h>
#include<assert.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<float.h>
#define ERROR -1
#define MAX 20000200
typedef struct
{
  int x,y,z;
} Coordinates;

Coordinates Tree[MAX];//binary heap 
int Index;            //the size of a heap

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

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

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

void setValue(Coordinates *coor, int x, int y, int z)
{
  coor->x = x;
  coor->y = y;
  coor->z = z;
}

void swap(Coordinates *a,Coordinates *b)
{
  Coordinates h = *a;
  *a = *b;
  *b = h;
}

// a > b
bool Compare(const Coordinates a,const Coordinates b)
{
  //?????????????????????????即????
  return a.x > b.x;
}


void maxHeapify(int i)
{
  int Left = getLeft(i);
  int Right = getRight(i);
  int largest;
 
  if(Left <= Index && Compare(Tree[Left],Tree[i]) ) largest = Left;
  else                                              largest = i;

  if(Right <= Index && Compare(Tree[Right],Tree[largest]) ) largest = Right;

  if(largest != i)
    {
      swap(&Tree[i],&Tree[largest]);
      maxHeapify(largest);
    }
}

int heapIncreaseKey(int i,Coordinates key)
{
  if(Compare(Tree[i],key))return ERROR;
  Tree[i] = key;
  int parent = getParent(i);
  while(i > 1 && Compare(Tree[i],Tree[parent]))
    {
      swap(&Tree[i],&Tree[parent]);
      i = parent;
    }
}

Coordinates heapExtractMax()
{
  assert(Index >= 1);//heap underflow
  Coordinates Max = Tree[1];
  Tree[1] = Tree[Index];
  Index--;
  maxHeapify(1);
  return Max;
}

void add_node(Coordinates value)
{
  Coordinates dummy;
  setValue(&dummy,INT_MIN,INT_MIN,INT_MIN);
  Tree[++Index] = dummy;
  heapIncreaseKey(Index,value);
}


int main()
{
  char op[1000];
  //double x,y,z;
  int x;

  while(1){
    scanf("%s",op);
    if(strcmp(op,"insert") == 0){
      scanf("%d",&x);
      Coordinates input;
      setValue(&input,x,INT_MIN,INT_MIN);
      add_node(input);
    }
    else if(strcmp(op,"extract") == 0){
      Coordinates output = heapExtractMax();
      printf("%d\n",output.x);
      //printf("%ld\n",heapExtractMax());
    }
    else if(strcmp(op,"end") == 0)break;
  }
 
  return 0;
}