#include<stdio.h>
#include<string.h>
int main(void)
{
    static int que[2000000];
    int i,j,n;
    char str[10];
    for(i=0;i<2000000;i++) que[i]=0;
    i=0;
    while(strcmp(str,"end")!=0){
        scanf("%s",str);
        if(strcmp(str,"insert")==0){
            scanf("%d",&n);
            j=i;
            while(n>que[j]){
                que[j+1]=que[j];
                j--;
            }
            que[j+1]=n;
            i++;
        }
        if(strcmp(str,"extract")==0){
            printf("%d\n",que[0]);
            for(j=0;j<i;j++) que[j]=que[j+1];
            i--;
        }
    }
    return 0;
}