#include<stdio.h>
#define INF 10000000
int h;
int A[2000000];

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 exact(){
  int max;
  if(h<1)return -INF;

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

  return max;
}


void heapIncreaseKey(int A[],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(A,h,k);
}

int main(){
  int k;
  char c[10];
  h = 0;
  while(1){
    scanf("%s",c);

    if(c[0] == 'e' && c[1] == 'n')break;
    else if(c[0] == 'i'){
      scanf("%d",&k);
      insert(k);
    }else{
      printf("%d\n",exact());
    }
  }

  return 0;
}