#include<stdio.h>
#define MAX 2000000
#define INFTY (1<<30)

int h, a[MAX+1];

void maxHeapify(int i){
	int l, r, largest, tmp;
	l = 2 * i;
	r = 2 * i + 1;
	
	if(l <= h && a[l] > a[i]){
		largest = l;
	} else {
		largest = i;
	}
	
	if(r <= h && a[r] > a[largest]){
		largest = r;
	}
	
	if(largest != i){
		tmp = a[i];
		a[i] = a[largest];
		a[largest] = tmp;
		maxHeapify(largest);
	}
}

int extract(){
	int max;
	
	if(h < 1){
		return -INFTY;
	}
	
	max = a[1];
	a[1]= a[h--];
	maxHeapify(1);
	return max;
}

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

void insert(int key){
	h++;
	a[h] = -INFTY;
	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;
}
	
