#include<stdio.h>
#include<string.h>
#define MAX 2000000
#define INF 1000
int H, A[MAX+1];

void heap(int i){
	int left, right, nodemax;
	int temp;
	left = 2 * i;
	right = 2 * i + 1;

	if(left <= H && A[left] > A[i] ){
		nodemax = left;
	}
	else nodemax = i;

	if(right <= H && A[right] > A[nodemax]){
		nodemax = right;
	}

	if(nodemax != i){
		temp = A[i];
		A[i] = A[nodemax];
		A[nodemax] = temp;
		heap(nodemax);
	}
}

int extract(){
	int max_ex;
	if( H < 1){
		return -INF;
	}
	max_ex = A[1];
	A[1] = A[H--];
	heap(1);
	return max_ex;
}

void increse(int i, int j){
	int temp;
	if(j < A[i]) return;
	A[i] = j;
	while(i > 1 && A[i/2] < A[i]){
		temp = A[i];
		A[i] = A[i/2];
		A[i/2] = temp;
		i = i/2;
	}
}

void insert(int i){
	H++;
	A[H] = -INF;
	increse(H,i);
}

int main(){
	int p;
	char com[10];

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