#include <stdio.h>
#include <limits.h>

#define MAX 2000001

static int H;
static int A[MAX];

static void maxHeapify(int i)
{
    int left = 2 * i;
    int right = 2 * i + 1;
    int largest;
    
    if (left <= H && A[left] > A[i]) {
        largest = left;
    } else {
        largest = i;
    }
    
    if (right <= H && A[right] > A[largest]) {
        largest = right;
    }
    
    if (largest != i) {
        int tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        maxHeapify(largest);
    }
}

static void increaseKey(int i, int key)
{
    A[i] = key;
    while (i > 1 && A[i / 2] < A[i]) {
        int tmp = A[i / 2];
        A[i / 2] = A[i];
        A[i] = tmp;
        i /= 2;
    }
}

static void insert(int key)
{
    H++;
    A[H] = INT_MIN;
    increaseKey(H, key);
}

static int extract()
{
    int max;

    if (H < 1) {
        max = INT_MIN;
    } else {
        max = A[1];
        A[1] = A[H--];
        maxHeapify(1);
    }

    return max;
}

int main()
{
    int key;
    char command[10];

    for (;;) {
        scanf("%s", command);
        if (command[0] == 'e' && command[1] == 'n') {
            break;
        } else if (command[0] == 'i') {
            scanf("%d", &key);
            insert(key);
        } else {
            printf("%d\n", extract());
        }
    }

    return 0;
}
