#include<stdio.h>

#define MAX 500001
#define INF 2000000000

int h;

int parent(int i){
  return i / 2;
}

int left(int i){
  return 2 * i;
}

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

int maxHeapify(int *A, int i){
  int l,r,largest,buf;
  l = left(i);
  r = right(i);

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

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

void buildMaxHeap(int *A){
  int i;

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

void insert(int *A, int i){
  A[h] = i;
  
  ++h;
  buildMaxHeap(A);
}

void heapIncreaseKey(int *A,int i, int key){
  int buf;
  
  A[i] = key;
  while((i > 1) && (A[parent(i)] < A[i])){
    buf = A[parent(i)];
    A[parent(i)] = A[i];
    A[i] = buf;
    i = parent(i);
  }
}

void maxHeapInsert(int *A, int key){
  h = h + 1;
  A[h] = -INF;
  heapIncreaseKey(A,h,key);
}

int extractMax(int *A){
  int max;
  
  max = A[1];
  A[1] = A[h];
  h--;
  maxHeapify(A,1);

  return max;
}


int main(){
  int i,k,c[MAX];
  char com[20];

  h = 1;
  
  while(1){
    scanf("%s", com);
    if(com[0] == 'i'){
      scanf("%d",&k);
      maxHeapInsert(c,k);
    }
    else if(com[1] == 'x'){
      printf("%d\n",extractMax(c));
    }
    else if(com[1] == 'n'){
      break;
    }
   
  }

 
  
  return 0;
}


