#include<stdio.h>
#include<limits.h>
#define MAX 2000010

int heap[MAX];
int heap_size=0;

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

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

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

void maxHeapify(int i){
  int a, l, r, largest;
  l = i * 2;
  r = i * 2 + 1;
  if (l <= heap_size && heap[i] < heap[l]) largest = l;
  else largest = i;
  if (r <= heap_size && heap[largest] < heap[r]) largest = r;
  if (largest != i) {
    a = heap[i];
    heap[i] = heap[largest];
    heap[largest] = a;
    maxHeapify(largest);
  }
}

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

void heapIncreaseKey(i, key){
  int tmp;
  if(key<heap[i])return;
  heap[i]=key;
  while(i>1 && heap[parent(i)] < heap[i]){
    tmp = heap[i];
    heap[i] = heap[parent(i)];
    heap[parent(i)]=tmp;
    i=parent(i);
  }
}

void maxHeapInsert(int key){
  heap_size+=1;
  heap[heap_size]=-INT_MAX;
  heapIncreaseKey(heap_size, key);
}

void aaaaa(int a){
  int i, count=0;
  for(i=0; i<a; i++){
    count++;
  }
}

int heapExtractMax(){
  int max, a=10;
  if(heap_size<1)return;
  max=heap[1];
  heap[1]=heap[heap_size];
  heap_size-=1;
  maxHeapify(1);
  return max;
}

int main(){
  int i=1, n, pri, a=10;
  char com[10];
  while(1){
    scanf("%s", com);
    if(com[0]=='i'){
      scanf("%d", &heap[i]);
      maxHeapInsert(heap[i]);
      i++;
    }
    else if(com[1]=='x'){
      pri=heapExtractMax();
      if(pri!=-1)printf("%d\n", pri);
    }
    else break;
  }
  aaaaa(a);
  return 0;
}

