#include<stdio.h>
#include<string.h>
#define YOSHI 2000000

int A[YOSHI];
int size;

void maxHeapify(int i){
    int l,r,largest,t;
    
    l = 2 * i;
    r = 2 * i + 1;
    
    if(l <= size && A[l] > A[i]) largest = l;
    else largest = i;
    
    if(r <= size && A[r] > A[largest]) largest = r;
    
    if(largest != i){
        t = A[i];
        A[i] = A[largest];
        A[largest] = t;
        maxHeapify(largest);
    }
}

int extract(){
    int i;
    
    if(size < 1) return -200000000;
    
    i = A[1];
    A[1] = A[size--];
    maxHeapify(1);
    
    return i;
}

void increase(int i,int k){
    int num;
    
    if(k < A[i]) return;
    
    A[i] = k;
    
    while(i > 1 && A[i / 2] < A[i]){
        num = A[i];
        A[i] = A[i / 2];
        A[i / 2] = num;
        i = i / 2;
    }
}

void insert(int k){
    size++;
    A[size] = -200000000;
    increase(size,k);
}

int main(){
    char array[20];
    int k;
    while(1){
        scanf("%s",array);
        if(array[0] == 'i'){
            scanf("%d",&k);
            insert(k);
        }
        else if(strcmp(array,"extract") == 0){
            printf("%d\n",extract());
        }
        else break;
    }
}
