#include <stdio.h>

#define MAX 2000000

void insert( char* queue, int k );
int extractMax( char* queue );
void swap( int x, int y );
int GetMaxindex( int x, int y );

int S[MAX] = {};
int index = 0;


int extractMax( char* queue )
{
    int i = 1;
    int maxIndex = 0;
    int left = 0;
    int right = 0;
    int maxElement = S[1];
    S[1] = S[index];
    index--;
    
    while((i * 2) <= index)
    {
        left = i * 2;
        right = left + 1;
        maxIndex = ( right <= index ) ? GetMaxindex( left, right ) : left;
         
        if( GetMaxindex( maxIndex, i ) == maxIndex )
        {
            swap( maxIndex, i );
            i = maxIndex;
        }
        else
        {
            break;
        }
    }
    return maxElement;
}

void swap( int x, int y )
{
    int temp = S[x];
     
    S[x] = S[y];
    S[y] = temp;
}

int GetMaxindex( int x, int y )
{
    return ( S[x] > S[y] ) ? x : y ;
}

void insert( char* queue, int k )
{
    int leaf = 0;
    int node = 0;
    index++;
    S[index] = k;
    leaf = index;
    node = leaf / 2;
    
    while( (S[leaf] > S[node]) && leaf > 1 )
    {
        swap( leaf, node );
        leaf = node;
        node = leaf / 2;
    }
}

int main()
{
    char com[10];
    int k = 0;
    
    while(1)
    {
        scanf("%s",com);
        if(com[0] == 'e')
        {
            if(com[1] == 'x')   printf("%d\n",extractMax(&S[0]));
            else    break;
        }
        else if(com[0] == 'i')
        {
            scanf("%d",&k);
            insert(&S[0],k);
        }
    }
    return 0;
}

