#include <stdio.h>
#define MAX 2000000
#define INFTY 30
void insert(int key,int A[]);
int extract(int A[]);
void heap(int i,int A[]);
void increase(int i,int key,int A[]);

int A[MAX+1];
int H;

int main(void){
	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,A);
		}
		else{
			printf("%d\n",extract(A));
		}
	}
	
	return 0;
}


void insert(int key,int A[]){
	H++;
	A[H]=-INFTY;
	increase(H,key,A);
}

int extract(int A[]){
	int max;
	if(H<1){
		return -INFTY;
	}
	max=A[1];
	A[1]=A[H--];
	heap(1,A);
	return max;
}


void heap(int i,int A[]){
	int max;
	int a,b;
	int tmp;
	a=2*i;
	b=2*i+1;
	if(a<=H && A[a]>A[i]){
		max=a;
	}
	else {
		max=i;
	}
	
	if(b<=H && A[b]>A[max]){
		max=b;
	}
	if(max!=i){
		tmp=A[i];
		A[i]=A[max];
		A[max]=tmp;
		heap(max,A);
	}
}

void increase(int i,int key,int A[]){
	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;
	}
}
