#include <stdio.h>
#include <string.h>
#define M 2000000
#define I (1<<30)

int H,A[M+1];

void maxheapify(int i){
    int l,r,largest,cng;
    l=2*i;
    r=2*i+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){
        cng=A[largest];
        A[largest]=A[i];
        A[i]=cng;
	maxheapify(largest);
    }
}

int extract(){
    int v;
    if(H<1)return -I;
    v=A[1];
    A[1]=A[H--];
    maxheapify(1);
    return v;
}

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

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

int main(){
    int key;
    char s[10];

    while(1){
        scanf("%s",s);
        if(s[0]=='e' && s[1]=='n')break;
        if(s[0]=='i'){
            scanf("%d",&key);
            insert(key);
        }else{
            printf("%d\n",extract());
        }
    }
    return 0;
}

