#include <stdio.h>
#include <stdlib.h>
#define MAX 2000000

int H;
int A[MAX+1];

void insert(int);
void heapIncreaseKey(int *, int, int);
int heapExtractMax(int *);
void maxHeapify(int *, int);

int main(){
  int key;
  char k[10];

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

  return 0;
}

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

void heapIncreaseKey(int *A, int i, int key){
  int tem;
  
  if(key < A[i]) return;
  A[i]=key;
  while(i > 1 && A[i/2] < A[i]){
    tem=A[i];
    A[i]=A[i/2];
    A[i/2]=tem;
    i=i/2;
  }
}

int heapExtractMax(int *A){
  int max;
  
  if(H < 1) return -MAX;
  max=A[1];
  A[1]=A[H];
  H--;
  maxHeapify(A, 1);

  return max;
}

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

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

  if(largest != i){
    tem=A[i];
    A[i]=A[largest];
    A[largest]=tem;
    maxHeapify(A, largest);
  }
}
 

