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

void insert(int);
int heapExtractMax(void);
void heapIncreaseKey(int); 
void maxHeapify(int i);
int parentNode(int i);
int leftChild(int i);
int rightChild(int i);

int A[2000001];
int heap_size;

main(){

  int i, key;
  char com[8];

  while(scanf("%s",com), strcmp(com,"end")){
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    if(com[0]=='e'){
      printf("%d\n",heapExtractMax());
    }
  }

  return 0;

}

void insert(int key){

  heap_size++;
  A[heap_size] = -1;
  heapIncreaseKey(key);

}

void heapIncreaseKey(int key){

  int i = heap_size, tmp;

  if(key < A[i]){
    printf("Error ??属????????????????????即????????????????属???????");
    return;
  }
  A[i] = key;
  while(i > 1 && A[parentNode(i)] < A[i]){
    tmp = A[parentNode(i)];
    A[parentNode(i)] = A[i];
    A[i] = tmp;
    i = parentNode(i);
  }

}

int heapExtractMax(void){

  int max;
  if(heap_size < 1){
    printf("Error ???????????蔵??????????????????");
    return;
  }
  max = A[1];
  A[1] = A[heap_size];
  heap_size--;
  maxHeapify(1);
  return max;

}
 
void maxHeapify(int i){
    int l = leftChild(i);
    int r = rightChild(i);
    int largest, tmp;
     
    if(l <= heap_size && A[l] > A[i]){
        largest = l;    
    }else{
        largest = i;
    }
    if(r <= heap_size && A[r] > A[largest]){
        largest = r;    
    }
    if(largest != i){
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        maxHeapify(largest);
    }
}

int parentNode(int i){
    return (int)i/2;
}
 
int leftChild(int i){
    return 2*i;
}
 
int rightChild(int i){
    return 2*i+1;
}