#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001

int A[MAX],pos;

void maxHeapify(int *A,int x){

  int largest,l,r,temp;

  l = 2*x;
  r = (2*x)+1;

  if(l<=x && A[l]>A[x])
    largest = l;
  else
    largest = x;

  if(r<=x && A[r]>A[largest])
    largest = r;
  
  if(largest != x){
    temp = A[x];
    A[x] = A[largest];
    A[largest] = temp;
    maxHeapify(A,largest);
  }
}

void insert(int *A,int k){

  int temp, i;

  pos++;
  A[pos] = k;

  i = pos;
  while(i>1 && A[i/2] < A[i]){
    temp = A[i];
    A[i] = A[i/2];
    A[i/2] = temp;
    i = i/2;
  }

  //printf("ins, i = %d\n", pos);
}



void extractMax(int *A){

  printf("%d\n",A[1]);
  A[1] = A[pos];
  pos--;
  maxHeapify(A, pos);
  
  //printf("del i = %d, A[1] = %d\n", pos, A[1]);
}

int main(void){
  
  int k;
  char c[10];
  pos = 0;

  while(1){
    scanf("%s",c);
    if(strcmp(c,"insert")==0){
      scanf("%d",&k);
      insert(A,k);
    }

    else if(strcmp(c,"extract")==0){
      extractMax(A);
    }

    else break;

  }
  return 0;
}