#include <stdio.h>
#include <stdlib.h>
#define MAX_NODES 2000000
#define INF 1010001000

int queue[MAX_NODES];

int pop(void);
void init(void);
void push(int x);
int sz;

int main(void)
{
    int tmp;
    char input[11];
    //init();
    while (scanf("%s", input)) {
        if (input[0] == 'i') {
            scanf("%d", &tmp);
            push(tmp);
        } else if (input[1] == 'x') {
            printf("%d\n", pop());
        } else {
            break;
        }
    }
    return 0;
}


void init(void)
{
    int i;
    for (i = 0; i < MAX_NODES; i++) {
        queue[i] = INF;
    }
}

void push(int x)
{
    int i = sz++, p;
    while (i > 0) {
        p = (i - 1) / 2;
        if (queue[p] >= x) {
            break;
        }
        queue[i] = queue[p];
        i = p;
    }
    queue[i] = x;
}

int pop(void)
{
    int i = 0, a, b;
    int ans = queue[0], x = queue[--sz];
    while (i * 2 + 1 < sz) {
        a = i * 2 + 1;
        b = i * 2 + 2;
        if (b < sz && queue[b] > queue[a]) { 
            a = b;
        }
        if (queue[a] <= x) {
            break;
        }
        queue[i] = queue[a];
        i = a;
    }
    queue[i] = x;
    //queue[sz] = INF;
    return ans;
}