#include<stdio.h>
#include<stdlib.h>

#define N 2000000
#define infty 1000000000

int n = 0, A[N];

void max_heapify(int);
int parent(int);
int right(int);
int left(int);
int extract(void);
void increase_key(int, int);
void insert(int);

int main(){
  char com[10];
  int num;

  while(1){
    scanf("%s", com);

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

    else if(com[0] == 'i'){
      scanf("%d", &num);
      insert(num);
    }

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

  return 0;
}

void max_heapify(int i){
  int l, r, biggest, tmp;

  l = left(i);
  r = right(i);

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

  else
    biggest = i;

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

  if(biggest != i){
    tmp = A[i];

    A[i] = A[biggest];
    A[biggest] = tmp;

    max_heapify(biggest);
  }
}

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

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

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

int extract(){
  int max;
    
  max = A[1];
  A[1] = A[n];
  n--;
  max_heapify(1);

  return max;
}

void increase_key(int i, int num){
  int temp;
  
  if(num < A[i])
    return;

  A[i] = num;

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

    i = parent(i);
  }
}

void insert(int num){
  n++;
  A[n] = -infty;
  increase_key(n, num);
}

