#include<stdio.h>
#include<string.h>

#define Max 2000000
#define Infty (1<<30)

int h, a[Max + 1];

void maxHeapify(int i){
  int l, r, largest, n;
  l = 2 * i;
  r = 2 * i + 1;

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

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

  if(largest != i){
    n = A[i];
    A[i] = A[largest];
    A[largest] = n;

    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if(h < 1) return -Infty;
  maxv = a[1];
  a[1] = a[h--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key){
  int n;

  if(key < a[i]) return;
  a[i] = key;
  while(i > 1 && a[i / 2] < a[i]){
    n = a[i];
    a[i], = a[i / 2];
    a[i / 2] = n;
    i = i / 2;
  }
}

void insert(int key){
  h++;
  a[h] = -Infty;
  increaseKey(h, key);
}


int main(){
  int key;
  char com[10];

  while(1){
    scanf("%s", com);
    if(com[0] == 'e' && com[1] == 'n') break;
    if(com[0] == 'i'){
      scanf("%d", &key);
      insert(key);
    }
    else{
      printf("%d\n", extract());
    }
  }

  return 0;
}
