#include<stdio.h>
#define MAX 2000000
#define INF (1<<30)

int H, S[MAX+1];

void swap(int *a, int *b){
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}

void maxHeapify(int i){
  int l = i * 2, r = i * 2 + 1, largest, temp;
  if(l <= H && S[l] > S[i])
    largest = l;
  else
    largest = i;

  if(r <= H && S[r] > S[largest])
    largest = r;
  if(largest != i){
    swap(&S[i], &S[largest]);
    maxHeapify(largest);
  }
}

int extractMax(){
  int maxid;
  if(H < 1) return -INF;
  
  maxid = S[1];
  S[1] = S[H--];
  maxHeapify(1);
  return maxid;
}

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

void insert(int key){
  H++;
  S[H] = -INF;
  increaseKey(H, key);
}

int main(){
  int key;
  char order[8];
  while(1){
    scanf(" %s", order);
    if(order[0] == 'e' && order[1] == 'n'){
      break;
    }
    if(order[0] == 'i'){
      scanf("%d", &key);
      insert(key);
    }else if(order[0] == 'e'){
      printf("%d\n", extractMax());
    }
  }
  return 0;
}

