#include<stdio.h>
#define INF 100000000

int h=0,T=2000000,A[2000000];

void insert(int);
int extra(void);

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

void maxHeapify(int i){
  int l = left(i);
  int r = right(i);
  int large;
  int tmp;

  if(l <= h && A[l] > A[i]){
    large = l;
  }else{
    large = i;
  }
  if(r <= h && A[r] > A[large]){
    large = r;
  }

  if(large != i){
    tmp = A[i];
    A[i] = A[large];
    A[large] = tmp;
    maxHeapify(large);
  }
}


int extra(){
  int max;
  if(h<1)return -INF;

  max = A[1];
  A[1] = A[h--];
  maxHeapify(1);

  return max;
}


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

  A[i] = k;

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

void insert(int k){
  h++;
  A[h] = -INF;
  heapIncreaseKey(h,k);
}

int main(){
	int i,n,k;
	char s[10];
	scanf("%s",s);
	while(s[2]!='d' ){
		if(s[0]=='i'){
			scanf("%d",&n);
			insert(n);
		}else{
			k=extra();
			printf("%d\n",k);
		}
		scanf("%s",s);
	}
	return 0;
}

