#include <stdio.h>
#define X 100000000
int n;
int A[20000000];
int Count();
void maxHeapify(int i);
void increaseKey(int n, int k);
void insert(int k);
int extractMax();
int main(){
  int i, c;
  char dist[20];
  for (i = 1; i <= 2000000; i++){
    scanf("%s", dist);
    if(dist[0] == 'i'){ // insert
      scanf("%d", &c);
      insert(c);
    } else if (dist[1] == 'x'){ // extract
      printf("%d\n", extractMax());
    } else if (dist[1] == 'n'){ // end
      break; }
  }
  return 0; }
int Count(){
  int i;
  for(i = 1; A[i] != 0; i++){
  }
  return i;
}
void maxHeapify(int i){
  int l, r, large, tmp, k;
  l = 2*i;
  r = 2*i+1;
  if(l<= n && A[l] > A[i]){
    large = l;
  } else large = i;
  if(r<= n && A[r] > A[large]){
    large = r;
  }
  if(large != i){
    tmp = A[i];
    A[i] = A[large];
    A[large] = tmp;
    maxHeapify(large);
  } }
void increaseKey(int n, int k){
  int tmp;
  A[n] = k;
  while(n>1 && A[n/2] < A[n]){
    tmp = A[n];
    A[n] = A[n/2];
    A[n/2] = tmp;
    n = n/2; }
}
void insert(int k){
  int i;
  n++;
  A[n] = -X;
  increaseKey(n, k);
}
int extractMax(){
  int i, max;
  maxHeapify(1);
  max = A[1];
  A[1] = A[n];
  n--;
  maxHeapify(1);
  return max;
}

