#include<stdio.h>
#include<limits.h>
#define M 2000000

int n;
int S[M];

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 i,int k){
  int tmp;
  if(k < S[i]) {
    printf("error");
    return;
  }
  S[i] = k;
  while(i > 1 && S[parent(i)] < S[i]){
    tmp=S[i];
    S[i]=S[parent(i)];
    S[parent(i)]=tmp;
    i = parent(i);
  }
}

void insert(int k){
  
  n++;
  S[n] = INT_MIN;
  heapIncreaseKey(n, k);
}

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

int exstractMax(){
  int mm;
  if(n < 1){
    return 0;
  }
  mm = S[1];
  S[1] = S[n];
  n--;
  maxHeapify(1);
  return mm;
}

int main(void){
  int i, k;
  char in[20];
  while(1){
    scanf("%s", in);
    if(in[0] == 'i'){
      scanf("%d", &k);
      insert(k);
    }
    else if(in[1] == 'x') printf("%d\n", exstractMax());
    else break;
  }
  
  return 0;
}