#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define N 2000000
#define INF 2000000000
int size;

void increase(int *A,int i,int key){
  int tmp;
  int p = floor(i/2);
  A[i] = key;
  while(i>1 && A[p]<A[i]){
    tmp=A[i];
    A[i]=A[p];
    A[p]=tmp;
    i = p;
  }
}

void insert(int *A,int key){
  size++;
  A[size]=-INF;
  increase(A,size,key);
}

void Heapify(int *A,int i){
  int l,r,tmp;
  int largest;
  l = i*2;
  r = i*2+1;
  if(l <size && A[l]>A[i]) largest = l;
  else largest = i;
  if(r <size && A[r]>A[largest]) largest = r;
  if(largest != i){
    tmp = A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    Heapify(A,largest);
  }
}
void extract(int *A){
  int max;
  max = A[1];
  A[1] = A[size];
  size--;
  Heapify(A,1);
  printf("%d\n",max);
}

int main(){
  char com[20];
  int x,i;
  int A[N];
  size =0;
  while(com[2]!='d'){
    scanf("%s",com);
    if(com[0] == 'i' ){
      scanf("%d", &x);
      insert(A,x);
    }
    else if (com[1] == 'x'){
      extract(A);
    }
  }
  return 0;
}