#include<stdio.h>

int heap[2000000];
int tail;

void insert(int k){
    int child = tail;
    int parent = (child - 1) / 2;

    heap[tail] = k;

    while(1){
        if(heap[parent] > heap[child] || child == 0)
            break;
        int tmp = heap[child];
        heap[child] = heap[parent];
        heap[parent] = tmp;

        child = parent;
        parent = (child - 1) / 2;
    }

    tail++;
}

int extract_max(){
    int ret = heap[0];
    int parent = 0;
    while(1){
        int l = 2 * parent + 1;
        int r = l + 1;
        if(tail <= l)
            break;
        if(tail == l + 1){
            heap[parent] = heap[l];
            break;
        }
        if(heap[l] > heap[r]){
            heap[parent] = heap[l];
            parent = l;
        }else{
            heap[parent] = heap[r];
            parent = r;
        }
    }
    tail--;
    return ret;
}

int main(){
    char cmd[8];
    int k;

    while(1) {
        scanf("%s", cmd);
        if(cmd[0] == 'i'){
            scanf("%d", &k);
            insert(k);
        }else if(cmd[1] == 'x'){
            printf("%d\n", extract_max());
        }else{
            return 0;
        }
    }
}