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

#define MAX 2000001
#define INFTY 100000000

int A[MAX+1], h, k;

void maxHeapify(int );
void increasekey(int ,int );
void insert(int );
void extract(void );

int main(){
  int k;
  char s[20];

  while(1){
    scanf("%s", s);
    
    if(s[0] == 'e' && s[1] == 'n' && s[2] == 'd') break;
    else if(s[0] == 'i' && s[1] == 'n' && s[2] == 's' && s[3] == 'e' && s[4] == 'r' && s[5] == 't'){
      scanf("%d", &k);
      insert(k);
    }
    else if(s[0]=='e' && s[1] == 'x' && s[2] == 't' && s[3] == 'r' && s[4] == 'a' && s[5] == 'c' && s[6] == 't')
      extract();
  }

  return 0;
}



void maxHeapify(int k){
  int temp;
  int left, right, big;
  int e;
  
  left = 2*k;
  right = 2*k+1;

  if(left <= h && A[k] < A[left]) big = left;
  else big = k;
  
  if(right <= h && A[big] < A[right]) big = right;
  if(big != k){
    temp = A[k];
    e--;
    A[k] = A[big];
    A[big] = temp;
    maxHeapify(big);
  }

  return ;
}

void increasekey(int i, int k){
  int temp;
  int z;
  
  A[i] = k;
  
  while(i>1 && A[i] > A[i/2]){
    temp = A[i];
    A[i] = A[i/2];
    z++;
    A[i/2] = temp;
    i = i/2;
  }

  return ;
}


void insert(int k){
  int x;
  
  h++;
  A[h] = INFTY*(-1);
  x++;
  increasekey(h, k);

  return ;
}

void extract(){
  int y;
  
  printf("%d\n", A[1]);
  A[1] = A[h--];
  y++;
  maxHeapify(1);

  return ;
}


