#include <stdio.h>
#include <limits.h>
#define MAX_H 2000000
int H;

int parent(int i) {return i / 2;}
int left(int i) {return 2 * i;}
int right(int i) {return 2 * i + 1;}


void MaxHeapif(int A[], int i) {
	int l, r, largest, tmp;
	l = left(i);
	r = right(i);
	
	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;
		MaxHeapif(A, largest);
	}
}

void buildMaxHeap(int A[]) {
	int i;
	for (i = H/2; i > 0; --i) {
		MaxHeapif(A, i);
	}
	return;
}

void heapIncreaseKey(int A[], int i, int key) {
	int tmp;
	if (key < A[i]) return;
	A[i] = key;

	while (i > 1 && A[parent(i)] < A[i]) {
		tmp = A[i];
		A[i] = A[parent(i)];
		A[parent(i)] = tmp;
		i = parent(i);
	}
	
	return;
}

void insert(int A[], int key) {
	H++;
	A[H] = INT_MIN;
	heapIncreaseKey(A, H, key);
}

int heapExtractMax(int A[]) {
	int max;
	
	if (H < 1) return 0;

	max = A[1];
	A[1] = A[H];
	H--;
	MaxHeapif(A, 1);

	return max;
		
}

int main(void) {
	int key, A[MAX_H+1] = {0};
	char com[20] = {0};
	H = 0;

	

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

	return 0;
}