#include <stdio.h>

#define MAX 2000000

void maxHeapify(int *, int);
void buildMaxHeap(int *);
void insert(int *, int);
int extractMax(int *);

int H=0;

int main(void)
{
	int k, Q[MAX+1];
	char com[10];
	
	while (1) {
		scanf("%s",com);
		if (com[0]=='e' && com[1]=='n') break;
		if (com[0]=='i') {
			scanf("%d",&k);
			insert(Q, k);
		} else {
			printf("%d\n", extractMax(Q));
		}
	}
	
	return 0;
}

void maxHeapify(int *A, int i)
{
	int l, r, largest, temp;
	
	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) {
		temp = A[i];
		A[i] = A[largest];
		A[largest] = temp;
		maxHeapify(A, largest);
	}
}

void buildMaxHeap(int *A)
{
	int i;
	
	for (i=H/2; i>=1; i--) {
		maxHeapify(A, i);
	}
}

void insert(int *A, int k)
{
	A[++H] = k;
}

int extractMax(int *A)
{
	int max;
	
	buildMaxHeap(A);
	max = A[1];
	A[1] = A[H--];
	return max;
}