#include <stdio.h>
#include <stdlib.h>
#define INF 10000000

void insert(int);
void maxHeapify(int);
void increaseKey(int,int);
void swap(int,int);
int extractMax(void);
int parent(int);
int left(int);
int right(int);

int heap[10000000],h=1;

int main(){
 int n=0, i, x,ans[100000000];
  char com[20];

  while(1){
    scanf("%s", com);
    if(com[0]=='e'&& com[1]=='n') break;
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'e'&& com[1]== 'x' ){
      ans[n] = extractMax();
      n++;
    } 
  }

  for(i=0;i<n;i++)printf("%d\n",ans[i]);
  return 0;
}

void insert(int i){
 h = h + 1;
 heap[h] = -INF;
 increaseKey(h,i);
}

int extractMax(void){
  int max;
if(h<1)return -INF;
max = heap[1];
heap[1] = heap[h];
h = h - 1;
maxHeapify(1);
return max;
}

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

void maxHeapify(int i){
  int l,r,largest;

  l = left(i);
  r = right(i);

  if(l <= h && heap[l] > heap[i]) largest = l;
  else largest = i;

  if(r <= h && heap[r] > heap[largest]) largest = r;

  if(largest != i){
    swap(i,largest);
    maxHeapify(largest);
  }
}

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

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

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

void swap(int a,int b){
int temp;

temp = heap[a];
heap[a] = heap[b];
heap[b] = temp;

}