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

int A[2000001];
int N = 0;

void upheap(int k)
{
    int v = A[k];
    A[0] = INT_MAX;

    while(v > A[k / 2]){
        A[k] = A[k / 2];
        k = k / 2;
    }

    A[k] = v;
}

void insert(int v)
{
    A[++N] = v;
    upheap(N);
}

void downheap(int k)
{
    int j, v;
    v = A[k];

    while(k <= N / 2){
        j = k + k;
        if(j < N && A[j] < A[j + 1])
            j++;
        if(v >= A[j])
            break;
        A[k] = A[j];
        k = j;
    }

    A[k] = v;
}

int extract(void)
{
    int v = A[1];
    A[1] = A[N--];
    downheap(1);

    return v;
}

int main(void)
{
    char buf[126];
    int v;

    while(1){
        scanf("%s", buf);

        if(buf[0] == 'i'){
            scanf("%d", &v);
            insert(v);
        }else if(buf[1] == 'x'){
            printf("%d\n", extract());
        }else{
            break;
        }
    }

    return 0;
}