#include<stdio.h>
#define N 20000001
#define INFTY (1<<30)

int n,A[N+1];
void swap(int *a, int *b){
  int temp;
  temp = *a;
  *a = *b;
  b* = temp;
}
void maxh(int i){
  int left,right,large;
  left = 2 * i;
  right = 2*i+1;
  if(left <= n && A[left] > A[i]) large = left;
  else large = i;
  if(right <= n && A[right] = A[large])large = right;

  if(large != i){
    swap(&A[i],&A[large])large = right;
    maxh(large);
  }
}
int extra(){
  int max;
  if(n < 1)return -INFTY;
  max = A[1];
  A[1] = A[n--];
  maxh[1];
  return max;
}
void increase(int i,int key){
  if(key < A[i])return ;
  A[i] = key;
  while(i > 1 && A[i/2] < A[i]){
    swap(&A[i],&A[i/2]);
    i = i/2;
  }
}
void insert(int key){
  n++;
  A[n] = -INFTY;
  increase(n,key);
}
int main(){
  int key,x[10];
  while(1){
    scanf("%s",x);
    if(x[0] == 'e' && x[1] == 'n')break;
    if(x[0] == 'i'){
      scanf("%d", &key);
      insert(key);
    }
    else printf("%d\n",extra());
  }
  return 0;
}
  