#include<stdio.h>
#define MAX 2000000
#define INF (1<<30)
void maxheapify(int);
int extract();
void increasekey(int,int);
void insert(int);
int G,N[MAX+1];

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

void increasekey(int i,int key){
  int a;
  if(key < N[i]){
    return;
  }
  N[i]=key;
  while(i > 1 && N[i/2] < N[i]){
    a=N[i];
    N[i]=N[i/2];
    N[i/2]=a;
    i=i/2;
  }
}
int extract(){
  int m;
  if(G<1){
    return -INF;
  }
    m=N[1];
    N[1]=N[G--];
    maxheapify(1);
    return m;
}

void maxheapify(int i){
  int a,k,e,largest;
  k=2*i;
  e=2*i+1;
  if(k<=G && N[k] > N[i])largest = k;
  else largest = i;
  if(e <= G && N[e] > N[largest])largest = e;
  if(largest != i){
    a=N[i];
    N[i]=N[largest];
    N[largest]=a;
    maxheapify(largest);
  }
}
void insert(int k){
  G++;
  N[G]=-INF;
  increasekey(G,k);
}


