#include<stdio.h>
#define MAX 2000000
#define INF (1<<30)
int H,A[MAX+1];

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

  c=*a;
  *a=*b;
  *b=c;

}

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

  if(l<=H && A[l]>A[i]) large=l;
  else large=i;
  if(r<=H && A[r]>A[large]) large=r;

  if(large!=i){
    swap(&A[i],&A[large]);
    maxHeapify(large);
  }
}

int extract(){
  int v;
  if(H<1) return -INF;
  v=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return v;
}

void increase(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;
  increase(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;

}