#include<stdio.h>

#define H 2000000
#define INFTY 2000000001

void maxHeapify(int*,int);
void buildMaxHeap(int*);
int heapMaximum(int*);
int heapExtractMax(int*);
void maxHeapInsert(int*,int);
void heapIncreaseKey(int*,int,int);


int n=0;

int main(void){
  char com[8];
  int key,Node[H];
  int i;

  while(1){
    scanf(" %s",com);
    if(com[0] == 'i'){
      scanf(" %d",&key);
      maxHeapInsert(Node,key);
    }
    else{
      if(com[1] == 'x'){
	printf("%d\n",heapExtractMax(Node));
      }
      else{
	break;
      }
    }
  }
  
  return 0;
}

void maxHeapify(int *A, int i){
  int l,r,largest,tmp;
  l = 2*i;
  r = 2*i+1;
  
  if(l <= n && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= n && A[r] > A[largest]) largest = r;

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

void buildMaxHeap(int *A){
  int i;

  for(i = n/2; i >= 1; i--){
    maxHeapify(A,i);
  }
}

int heapMaximum(int *A){
  return A[1];
}

int heapExtractMax(int *A){
  int max;
  max = A[1];
  A[1] = A[n];
  n--;
  maxHeapify(A,1);
  return max;
}

void maxHeapInsert(int *A, int key){
  n++;
  A[n] = -INFTY;
  heapIncreaseKey(A,n,key);
}

void heapIncreaseKey(int *A, int i, int key){
  int tmp;
  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;
  }
}

