#include <stdio.h>
#include <string.h>
#define NIL -2000000001
#define MAX 40000000
#define DELETED -1

int S[MAX];

int main(void){
  int i, k;
  char order[10];
  int largest = 0;
  int largestindex = 0;
  int end = 0;

  for(i = 0 ; i < MAX; i++)
    S[i] = NIL;

  while(1){

    scanf("%s", order);
    if(strcmp(order, "end") == 0)break;

    if(strcmp(order, "insert") == 0){
      scanf("%d", &k);
      S[end] = k;
    end++;
    }

    if(strcmp(order, "extract") == 0){
      largest = 0;
      for(i = 0; i < end; i++){
        if(S[i] > largest){
          largest = S[i];
          largestindex = i;
        }
      }
      printf("%d\n", largest);
      S[largestindex] = DELETED;
    }
  }

  return 0;
}