#include <stdio.h>
#define NIL -1
#define MAX 2000005
#define MIN -100000000

int T[MAX];
int hs;

void swap(int, int);
void maxHeapify(int);
void heapIncreaseKey(int, int);


int main()
{
  int i, a;
  char c[10];
 
  for(i=0; i<MAX; i++){
    A[i]=NIL;
  }

  for(i=1; ;i++){
    scanf("%s ",c);

    if(c[0]=='i'){
      scanf("%d", &a);
      maxHeapInsert(a);
    }
    else if(c[1]=='x'){
      a = heapExtractMax();
      printf("%d\n",a);
    }
    else break;
  }
  return 0;
}
  

void swap(int x, int y)
{
  int temp;
  temp=A[x];
  A[x]=A[y];
  A[y]=temp;
}


void maxHeapify(int i)
{
  int l = left(i);
  int r = right(i);
  int largest;

  if(l <= hs && A[l] > A[i]){
	largest = l;
  }
  else{
	largest = i;
  }
  if(r <= hs && A[r] > A[largest]){
	largest = r;
  }
  if(largest != i)
	{
	  swap(i, largest);
	  maxHeapify(largest);
	}
}


void heapIncreaseKey(int i, int key)
{
  if(key < A[i]) return;

  A[i] = key;
  while(i>1 && A[parent(i)] < A[i]){
    swap(i, parent(i));
    i = parent(i);
  }
}


void maxHeapInsert(int key)
{
  hs = hs + 1;
  A[hs] = MIN;
  heapIncreaseKey(hs, key);
}


int heapExtractMax()
{
  int max;

  if(hs < 1){
    return;
  }

  max = A[1];
  A[1] = A[hs];
  hs = hs - 1;
  maxHeapify(1);
  return max;
}

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


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


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