#include<stdio.h>
#define MAX 2000000

int H;

int parent(int i){
    return i/2;
}

int left(int i){
    return 2*i;
}

int right(int i){
    return 2*i+1;
}

void IncreaseKey(int *S,int i,int key){
    S[i]=key;
    int temp;
    while(i>1 && S[parent(i)]<S[i]){
        temp=S[i];
        S[i]=S[parent(i)];
        S[parent(i)]=temp;
        i=parent(i);
    }
}

void insert(int *S,int k){
    H++;
    IncreaseKey(S,H,k);
}



void maxHeapify(int *A,int i){
    int l,r,largest,temp;
    l=left(i);
    r=right(i);
    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(A,largest);
    }
}

int extractMax(int *A){
    int max;
    max=A[1];
    A[1]=A[H];
    H--;
    maxHeapify(A,1);
    return max;
}


int main(){
    int n, i, x;
    int ans,S[MAX];
    char com[20];
    for ( i = 0;; i++ ){
        scanf("%s", com);
        if ( com[0] == 'i' ){
            scanf("%d", &x);
            insert(S,x);
        } else if ( com[0] == 'e' && com[1] == 'x'){
            ans=extractMax(S);
            printf("%d\n",ans);
        } else if(com[1] == 'n'){
            return 0;
        }
    }
    return 0;
}

