#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 2000001
#define NIL -1

int n;
int a[N];

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

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

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

void heapIncreaseKey(int key){
  int tmp;
  if(key < a[n]){
    exit(1);
  }
  a[n] = key;
  while(n>1 && a[parent(n)] < a[n]){
    tmp = a[n];
    a[n] = a[parent(n)];
    a[parent(n)] = tmp;
    n = parent(n);
  }
}

void maxHeapInsert(int key){
    n = n + 1;
    a[n] = NIL;
    heapIncreaseKey(key);
}


void maxHeapify(int i){
  int largest=0,tmp;
  int l,r;
  l = left(i);
  r = right(i);
  if(l <= n && a[l] > a[i]){
    largest = l;
  }
  else
    largest = i;
  if(r <= n && a[r] > a[largest]){
    largest = r;
  }
  if(largest != i){
    tmp = a[i];
    a[i] = a[largest];
    a[largest] = tmp;
    maxHeapify(largest);
  }
}


int heapExtractMax(){
  int max;
  if(n < 1){
    exit(2);
  }
  max = a[1];
  a[1] = a[n];
  n = n-1;
  maxHeapify(1);
  return max;
}
   

void buildmaxheap(){
  int i;
  for(i = n/2; i>0; i--){
    maxHeapify(i);
  }
}      


main(){
  int key;
  char b[8];
  while(1){
    scanf("%s",b);
    if(b[0] == 'i'){
      scanf("%d",&key);
      maxHeapInsert(key);
    }
    else if(b[0] == 'e' && strlen(b) == 7){
      printf("%d\n",heapExtractMax(a));
     }
    else
      break;
       }
  return 0;
}