#include<stdio.h>

#define MAX 2000001
#define INF -2000000001

int size;

int A[MAX];

int left(int);

int right(int);

void increase(int, int);

void insert(int);

void maxHeapify(int);

int extractMax(void);


int main(){

  char com[10];

  int num;

  size = 0;

  while(1){

    scanf("%s", com);

    if(com[0] == 'i'){

      scanf("%d", &num);

      insert(num);

    }

    else if((com[0] == 'e') && (com[1] == 'x')){

      printf("%d\n", extractMax());

    }

    else if((com[0] == 'e') && (com[1] == 'n')){
      
      break;

    }

  }

  return 0;

}

int left(int x){

  return (2 * x);

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

}

void increase(int i, int key){

  int tmp;

  A[i] = key;

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

    tmp = A[i];
    
    A[i] = A[i / 2];

    A[i / 2] = tmp;

    i = (i / 2);

  }

}

void insert(int key){

  size++;

  A[size] == INF;

  increase(size, key);

}

void maxHeapify(int i){

  int l, r, largest, tmp;

  l = left(i);

  r = right(i);

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

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

  if(largest != i){

    tmp = A[i];

    A[i] = A[largest];

    A[largest] = tmp;

    maxHeapify(largest);

  }

}
 
int extractMax(){

  int max;

  max = A[1];

  A[1] = A[size];

  size--;

  maxHeapify(1);

  return max;

}