#include<stdio.h>
#include<string.h>
int H = 0;

void maxHeapify(int *A,int i){
  int largest,ch,l,r;
  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){
    ch = A[i];
    A[i] = A[largest];
    A[largest] = ch;
    maxHeapify(A,largest);
  }
}

void buildMaxHeap(int *A){
  int i;
  for(i = H/2;i >= 1; i--) maxHeapify(A,i);
}


void insert(int *A,int n){
  int i = H + 1,ch;
  H++;
  A[H] = n;
  while(i > 1 && A[i] > A[i/2]){
    ch = A[i];
    A[i] = A[i/2];
    A[i/2] = ch;
    i = i/2;
  }
}

int extract(int *A){
  int max;
  if(H < 1) printf("cannot extract\n");
  max = A[1];
  A[1] = A[H];
  H--;
  maxHeapify(A,1);
  return max;
}

int main(){
  int i,n;
  int A[2000000];
  char mai[20];
  while(1){
    scanf("%s",mai);
    if(mai[0] == 'i'){
      scanf("%d",&n);
      insert(A,n);
    }
    else if(mai[1] == 'x') printf("%d\n",extract(A));
    else break;
    }
  return 0;
}

