#include<stdio.h>
#include<string.h>

#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MAX 2000000
#define INFINITY (1<<30)

int h,A[MAX+1];

void maxHeapify(int i){
	int left,right,largest;
	left = 2*i;
	right = 2*i+1;
	
	if(left <= h && A[left] > A[i]){
		largest = left;
	}else{
		largest = i;
	}

	if(right <= h && A[right] > A[largest]){
	largest = right;
	}
	
	if(largest != i){
	SWAP(A[i],A[largest]);
	maxHeapify(largest);
	
	}
}

int extract(){
	int maxv;
	if(h < 1)return -INFINITY;
	maxv = A[1];
	A[1] = A[h--];
	maxHeapify(1);	
	return maxv;
}



void increaseKey(int i,int key){
	if(key < A[i])return;
	
	A[i] = key;
	while(i > 1 && A[i / 2] < A[i]){
		SWAP(A[i],A[i/2]);
		i = i/2;
	}
}

void insert(int key){
	h++;
	A[h] = -INFINITY;
	increaseKey(h,key);
	
}
	
int main(){
	int key;
	char com[10];
	
	while(1){
		scanf("%s",com);
		if(com[0] == 'e' && com[1] == 'n')break;
		if(com[0] == 'i'){
			scanf("%d",&key);
			insert(key);
		}else{
			printf("%d\n",extract());
		}
	
	}
	return 0;
}
