#include <stdio.h> 
#include <string.h>

#define INF 1000000000

int A[200000000];
int nmber = 0;
int H = 0;

void maxHeapify(int i){
    int l, r;
    int  largest, temp;
    

    l = i * 2;
    r = i * 2 + 1;

    if(l <= H && A[l] > A[i]) 
        largest = l;
    else 
        largest = i;

    if(r <= H && A[r] > A[largest])
        largest = r;
    
    if(largest != i){
        temp = A[i];
        A[i] = A[largest];
        A[largest] = temp;
        maxHeapify(largest);
    }
}

void increaseKey(int i, int key){
    int temp;
    if(key < A[i])return;

    A[i] = key;
    while(i > 1 && A[i/2] < A[i]){
        temp = A[i];
        A[i] = A[i/2];
        A[i/2] = temp;
        i = i / 2;
    }
}

int heapExtractMax(){
    int max;
    if(H < 1) return -INF;

    max = A[1];
    A[1] = A[H];
    H--;
    maxHeapify(1);

    return max;
}

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

int main(){
    int nm;
    char op[10];
  
    while(1){
        scanf("%s", op);
        if(strcmp(op, "insert") == 0){
            scanf("%d", &nm);
            insert(nm);
        }
        else if(strcmp(op, "extract") == 0){
            printf("%d\n", heapExtractMax());
        }
        else if(strcmp(op, "end") == 0)break;
    }

    return 0;
}

