#include<stdio.h>
#include<string.h>
#define MAX 2000001

int A[MAX],count;

void maxHeapify(int i){

  int large,tmp,left,right;

  left = 2*i;
  right = 2*i+1;

  if(left <= count && A[left] > A[i])large = left;
  else large = i;

  if(right <= count && A[right] > A[large])large = right;

  if(large != i){
    tmp = A[i];
    A[i] = A[large];
    A[large] = tmp;
    maxHeapify(large);
  }
}

int extractMax(){
  int max = A[1];
  A[1] = A[count];
  count--;
  maxHeapify(1);
  return max;
}

void increaseKey(int key){

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

void insert(int key){

  count += 1;
  A[count] = 0;
  increaseKey(key);

}

int main(){

  int key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(strcmp(com,"insert") == 0){
      scanf("%d",&key);
      insert(key);
    }
    else if(strcmp(com,"extract") == 0)printf("%d\n",extractMax());
    else if(strcmp(com,"end") == 0)break;
  }
  return 0;
}