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

#define MAX 2000000
#define INF 90000000

 int H,A[MAX+1],time=0;

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


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

  if(large != i){
    temp = A[i];
    A[i]=A[large];
    A[large] = temp;
    maxHeapify(large);
  }
}

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 temp;
  if(key < A[i])return;
  A[i] = key;
  while(i > 1 && A[i/2] < A[i]){
    //swap(A[i],A[i/2]);
    temp = A[i];
    A[i] = A[i/2];
    A[i/2] = temp;
    i = i/2;
  }
}


void insert(int key){
  H++;
  A[H] = -INF;
  increaseKey(H,key);
}

int main(){
  int key;
  char s[100];

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

