#include<stdio.h>
#include<stdlib.h>
int heapsize,tmp,A[20000000];
int parent(int i){
    return i/2;
}
int left(int i){
    return 2*i;
}
int right(int i){
    return 2*i+1;
}

void heapIncreaseKey(int i, int key){
    if(key<A[i]){
        return;
    }
    A[i]=key;
    while(i>1 && A[parent(i)<A[i]]){
        tmp=A[i];
        A[i]=A[parent(i)];
        A[parent(i)]=tmp;
        i=parent(i);
    }
}

void maxHeapInsert(int key){
    heapsize++;
    A[heapsize]=-2047;
    heapIncreaseKey(heapsize, key);
}

void maxHeapify(int i){
    int l,r,largest,tmp;
    l= left(i);
    r =right(i);
    if(l<=heapsize && A[l]>A[i])largest =l;
    else largest =i;
    if(r<=heapsize && A[r]>A[largest])largest=r;
    if(largest != i){
        tmp=A[i];
        A[i]=A[largest];
        A[largest]=tmp;
        maxHeapify(largest);
    }
}

int heapExtractMax(){
    int max;
    if(heapsize<1){
        return 0;
    }
    max=A[1];
    A[1]=A[heapsize];
    heapsize--;
    maxHeapify(1);
    return max;
}

int main(){
    char b[100];
    int j;
    while(1){
        scanf("%s",b);
        if(b[0] =='i') {
            scanf("%d",&j);
            maxHeapInsert(j);
            
        }
        else if(b[1]=='x'){
            printf("%d\n",heapExtractMax());
        }
        else break;
    }
    
    
    return 0;
    
}