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

#define N 2000000
#define INF 2147483647

int A[N],n=0;

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

void increase(int i,int k){
  int temp;
  
  if(k<A[i]) return;

  A[i]=k;

  while(i>1 && A[i/2]<A[i]){
    temp=A[i];
    A[i]=A[i/2];
    A[i/2]=temp;

    i=i/2;
  }

  return;
}

void insert(int k){
  n++;
  A[n]=-INF;
  increase(n,k);
}

void maxHeapify(int i){
  int l,r,largest,temp;

  l=2*i;
  r=2*i+1;

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

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

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

    maxHeapify(largest);
  }

  return;
}

int extract(){
  int max;
  
  if(n<1) return -INF;

  max=A[1];

  A[1]=A[n--];


  maxHeapify(1);

  return max;
}


int main(){
  int i,j=0,k;
  char com[20];

  while(1){
    scanf("%s",com);
    
    if(com[0]=='e' && com[1]=='n') break;
    
    if(com[0]=='i'){
      scanf("%d",&k);

      insert(k);
    }

    else{
      printf("%d\n",extract());
    }

  }

  return 0;
}
  
  
  

