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

#define MAX 5000001


int H = 0;

void swap(int* A, int i, int j) {
    int temp;
    temp = A[i];
    A[i] = A[j];
    A[j] = temp;
}

void maxheapify(int* A, int i) {
    int left, right, largest;
    left = 2 * i;
    right = 2 * i + 1;
    if (left <= H && A[left] > A[i]) largest = left;
    else largest = i;
    if (right <= H && A[right] > A[largest]) largest = right;

    if (largest != i) {
        swap(A, i, largest);
        maxheapify(A, largest);
    }
}

int heapextractmax(int* A) {
    int max;

    max = A[1];
    A[1] = A[H];
    H--;
    maxheapify(A, 1);
    return max;
}

void heapincreasekey(int* A, int i, int key) {
    A[i] = key;
    while (i > 1 && A[i / 2] < A[i]) {
        swap(A, i, i / 2);
        i = i / 2;
    }
}
void maxheapinsert(int* A, int key) {
    H++;
    heapincreasekey(A, H, key);
}

int main() {
    int max, A[MAX], k;
    char com[16];

    while (1) {
        scanf(" %s", com);
        if (com[0] == 'i') {
            scanf("%d", &k);
            maxheapinsert(A, k);
        }
        else if (com[1] == 'x') {
            max = heapextractmax(A);
            printf("%d\n", max);
        }
        else break;
    }

    return 0;
}

