// AOJ ALDS1_9_C Priority Queue
// 2018.4.27 bal4u

#include <stdio.h>

#define QSIZE 2000002

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

typedef struct { long long t; } QUE;
QUE que[QSIZE + 5];
int qsize;

void max_heapify(int i)
{
	int l, r, max;
	QUE qt;
	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t > que[i].t) max = l; else max = i;
	if (r < qsize && que[r].t > que[max].t) max = r;
	if (max != i) {
		qt = que[i], que[i] = que[max], que[max] = qt;
		max_heapify(max);
	}
}

void deq()
{
	que[0] = que[--qsize];
	max_heapify(0);
}

void enq(long long t)
{
	int i, max;
	QUE qt;

	i = qsize++;
	que[i].t = t;
	while (i > 0 && que[max = PARENT(i)].t < que[i].t) {
		qt = que[i]; que[i] = que[max], que[max] = qt;
		i = max;
	}
}


// バッファを経ずstdinから数値を得る
#define gc() getchar_unlocked()
//#define gc() getchar()
long long in()
{
	long long n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int main()
{
	int k;

	qsize = 0;
	while (1) {
		if (gc() == 'e') {
			if (gc() == 'n') break;
			k = 6; while (k--) gc();
			printf("%lld\n", que[0].t);
			deq();
		} else {
			k = 6; while (k--) gc();
			enq(in());
		}
	}
	return 0;
}

