#include<stdio.h>
#include<stdlib.h>

#define NIL -1


void maxHeapify(int *, int, int);
void buildMaxHeap(int *,int);
int extractMax(int *);
void insert(int *, int);

int size = 0;


int main(){

  char op[10];
  int key,i,A[2000];

  while(1){

    scanf("%s",op);
    
    if(op[0] == 'i') {
      scanf("%d",&key);
      insert(A,key);
    }
    
    else if(op[2] == 't') {
      printf("%d\n",extractMax(A));
    }

    else break;
  }    

  return 0;
  
}


void buildMaxHeap(int *A, int h){
  int i;
  for(i = h/2 ; i >= 1 ; i--)
    maxHeapify(A, i, h);
}

void maxHeapify(int *A, int i, int h){
  int l, r, largest,tmp;

  l = i*2;
  r = i*2+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){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A, largest, h);
  }

}


void insert(int *A, int key){
  int tmp,i;
  size++;
  i = size;

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




int extractMax(int *A) { 

  int max;

  max = A[1];
  A[1] = A[size];
  size--;
  maxHeapify(A, 1, size);

  return max;