#include <stdio.h>
#include <stdlib.h>

void insert(double *,int);
void heapIncreaseKey(double *,int, int);
int extractMax(double *);
void maxHeapify(double *, int);

int h=0;

int main()
{
  double H[200000];
  char c[10];
  int extract[200000];
  int i,j=0,k;

  while(1){
    scanf("%s",c);

    if(c[0]=='e'&& c[1]=='n') break;

      else if(c[0]=='e') {
      extract[j]=extractMax(H);
      j++;
      }

    else if(c[0]=='i'){
      scanf("%d",&k);
      insert(H,k);
    }
  }
  /* output */
  for(i=0;i<j;i++) printf("%d\n",extract[i]);

  return 0;
}

void insert(double *A,int k){
  h=h+1;
  A[h]=(-1)*(1.0/0.0);
  heapIncreaseKey(A,h,k);
}

void heapIncreaseKey(double *A,int i, int key){
  double B;

  if(key<A[i])  fprintf(stderr,"new key issamller than current key");
  A[i] = key;
  while(i>1 && A[i/2] < A[i]){
    B=A[i];
    A[i]=A[i/2];
    A[i/2]=B;
    i=(i/2);
  }
}

int extractMax(double *A){
  int max;
  if(h<1) fprintf(stderr,"heap underflow");
  max = A[1];
  A[1] = A[h];
  h--;
  maxHeapify(A,1);
  return max;
}

void maxHeapify(double *A, int i){
  int l,r,largest;
  double B;
  l = 2*i;
  r = 2*i+1;
  // 左の子、自分、右の子で値が最大のノードを選ぶ
  if(l <= h && A[l]>A[i]) largest=l;
  else largest = i;
  if(r <= h && A[r]>A[largest]) largest = r;
  if(largest!=i){
    B=A[i];
    A[i]=A[largest];
    A[largest]=B;

    maxHeapify(A, largest); // 再帰的に呼び出し
  }
}