#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX 2000000
#define INF 1<<21
void insert(int);
int H,A[MAX+1];
void maxHeapify(int);
void heapIncreasekey(int, int);
int main(void)
{
	int key;
	char com[20];
	
	while(1){
		scanf("%s",com);
		if(com[0]== 'e' && com[1] == 'n'){
			break;
		}
		if(com[0] == 'e' && com[1] == 'x'){
			
			printf("%d\n",extract());
		}
		if(com[0] == 'i'){
			scanf("%d",&key);
			insert(key);
		}
		
	}
	return 0;
}

void insert(int key){
	H++;
	A[H]=-INF;
	heapIncreasekey(H, key);//A[H]にkeyを設定する
}

void heapIncreasekey(int i,int key){
	if(key < A[i]){
		return;
	}
	A[i] = key;
	int tmp;
	while(i>1 && A[i/2]<A[i]){
		tmp = A[i/2];
		A[i/2] = A[i];
		A[i] = tmp;
		i= i/2;
	}
}
int extract(){
	int maxkey;
	if( H< 1 ) return -INF;
	maxkey = A[1];
	A[1] = A[H--];
	maxHeapify(1);
	return maxkey;
}
void maxHeapify(int i){
	  int tmp;
    int max;
    if(i*2<H+1 && A[i] < A[i*2]){
        max = i*2;
        //printf("left is largest\n");
    }
     
    else {
        max = i;
    //  printf("i is largest\n");
    }
    if(i*2+1 < H+1 && A[max] < A[i*2+1]){
        max = i*2+1;
    //  printf("right is largest\n");
    }
     
    if(max != i ){
        tmp  = A[max];
        A[max] = A[i];
        A[i] = tmp; 
        maxHeapify(max);
    }
}


