#include<bits/stdc++.h>//
using namespace std;
main()
 {
    // freopen("input","r",stdin);
    long long int t,i,j;
    priority_queue<long long> q;
    char s[15];
    while(scanf("%s",s) && s[2]!='d')
    {
        if(s[0]=='i')
        {
            scanf("%lld",&t;
           q.push(t);
        }
        else if(s[2]=='t')
        {
            i=q.top();
            q.pop();
            printf("%lld\n",i);
        }
    }
    return 0;
 }