#include <stdio.h>
#include <stdlib.h>
int heap_size = 0;
void maxHeapify(int* array, int i) {
    int l, r, largest;
    int work;
    l = i * 2;
    r = i * 2 + 1;
    if (l <= heap_size && array[l] > array[i]) {
        largest = l;
    } else {
        largest = i;
    }
    if (r <= heap_size && array[r] > array[largest]) {
        largest = r;
    }
    if (largest != i) {
        work = array[i];
        array[i] = array[largest];
        array[largest] = work;
        maxHeapify(array, largest);
    }
}
void heapIncreaseKey(int* array, int i, int key) {
    int work;
    array[i] = key;
    while (i > 1 && array[i / 2] < array[i]) {
        work = array[i];
        array[i] = array[i / 2];
        array[i / 2] = work;
        i = i / 2;
    }
}
void maxHeapInsert(int* array, int key) {
    heap_size++;
    array[heap_size] = -1;
    heapIncreaseKey(array, heap_size, key);
}
int heapExtractMax(int* array) {
    long max;
    max = array[1];
    array[1] = array[heap_size];
    heap_size--;
    maxHeapify(array, 1);
    return max;
}
int main() {
    char com[10];
    int heap[2000000];
    int arg;
    while (1) {
        scanf("%s", com);
        if (com[0] == 'i') {
            scanf("%d", &arg);
            maxHeapInsert(heap, arg);
        } else if (com[1] == 'x') {
            printf("%d\n", heapExtractMax(heap));
        } else {
            break;
        }
    }
     return 0;
}