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

int h, a[MAX+1];


void swap(int *a, int *b){
  int tmp;

  tmp = *a;
  *a = *b;
  *b = tmp;
}


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

  l = 2 * i;
  r = l + 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)
    swap(&a[i],&a[largest]);

  maxh(largest);
}

int ext(void){
  int maxv;

  if(h<1) return -INF;

  maxv = a[1];

  a[1] = a[h--];

  maxh(1);

  return maxv;
}

void inc(int i, int key){
  if(key<a[i]) return;

  a[i] = key;

  while(i>1 && a[i/2]<a[i]){
    swap(&a[i],&a[i/2]);

    i = i/2;
  }
}


void insert(int key){
  h++;

  a[h] = -INF;

  inc(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",ext());
  }
  return 0;
}