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

int heap[2000001];
int last_idx;


void maxHeapify(int node_idx){
    
    int tmp;
    int largest = node_idx;
    int left_child_idx = 2 * node_idx;
    int right_child_idx = 2 * node_idx + 1;
    
    
    if ( left_child_idx <= last_idx && heap[left_child_idx] > heap[node_idx]) {
        largest = left_child_idx;
    }else{
        largest = node_idx;
    }
    if ( right_child_idx <= last_idx && heap[right_child_idx] > heap[largest]) {
        largest = right_child_idx;
    }
    
    if (largest != node_idx) {
        tmp = heap[largest];
        heap[largest] = heap[node_idx];
        heap[node_idx] = tmp;
        
        maxHeapify(largest);
    }
}


void hIncreaseKey(int inserted_num ){
    int i = last_idx;
    int tmp;
    
    while( i > 1 && heap[i/2] < heap[i]){
        tmp = heap[i];
        heap[i] = heap[i/2];
        heap[i/2] = tmp;
        i = i/2;
    }
    
}

void insert(int inserted_num){
    last_idx++;
    heap[last_idx] = inserted_num;
    hIncreaseKey(inserted_num);
}

void extract(){
    printf("%d\n", heap[1]);
    heap[1] = heap[last_idx--];
    maxHeapify(1);
}


int main( ){
    
    int operand;
    char operator[20];
    
    while (1) {
        scanf("%s", operator);
        
        if (strcmp(operator, "insert") == 0) {
            scanf("%d", &operand);
            insert(operand);
        }
        else if(strcmp(operator, "extract") == 0){
            extract();
        }
        else{
            break;
        }
    }
    
    return 0;
}