#include<stdio.h>
#define MAX 2000010
#define OVERMIN -1

int heap[MAX];
int H = 0;

void swap(int i, int j) {
	int buf = heap[i];
	heap[i] = heap[j];
	heap[j] = buf;
}

void maxHeap(int H, int i) {
	int l = 2 * i, r = 2 * i + 1;
	int largest = i;
	if (l <= H && heap[l] > heap[i])largest = l;
	if (r <= H && heap[r] > heap[largest])largest = r;
	if (largest != i) {
		swap(i, largest);
		maxHeap(H, largest);
	}
}

void InsertKey(int H, int k) {
	int pos = H;
	if (heap[H] > k) {
		printf("Insertion Error\n");
		return;
	}
	else {
		heap[H] = k;
		while (pos / 2 > 0 && heap[pos] > heap[pos / 2]) {
			swap(pos, pos / 2);
			pos /= 2;
		}
	}
}

void Insert(int k) {
	H++;
	heap[H] = OVERMIN;
	InsertKey(H, k);
}

int extractMax() {
	int out = heap[1];
	heap[1] = heap[H];
	H--;
	maxHeap(H, 1);
	return out;
}

int main() {
	char input_str[10];
	int input_ele;

	while (1) {
		scanf("%s", input_str);
		if (input_str[0] == 'i') {
			scanf("%d", &input_ele);
			Insert(input_ele);
		}
		else {
			if (input_str[1] == 'x') {
				printf("%d\n", extractMax());
			}
			else break;
		}
	}

	return 0;
}
