#include <stdio.h>
#include <string.h>
#define MAX 2000000
#define INF 30

int h,a[MAX+1];

void maxheapify(int i){
  int l,r,largest,b;
  l = 2*i;
  r =2*i+1;
  if(l<=h&&a[l]>a[i]){
    largest = r;
  }
  else largest=i;
  if(r<=h&&a[r]>a[largest]){
    largest = r;
  }
  if(largest!=i){
    b = a[i];
    a[i] = a[largest];
    a[largest] = b;
    maxheapify(largest);
  }
}

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

void increasekey(int i,int key){
  int b;

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

void insert(int key){
  h++;
  a[h] = -INF;
  increasekey(h,key);
}
   
int main(){
  int k;
  char c[7];

  while(1){
    scanf("%s",c);
    if(strcmp(c,"end")==0) break;
    if(strcmp(c,"insert")==0){
      scanf("%d",&k);
      insert(k);
    }
    else printf("%d\n",extract());
  }
  return 0;
}