#include <stdio.h>
#define MAX 2000000
#define INF 2147483647

void maxHeapify(int *,int);
int heapExtractMax(int *);
void maxHeapInsert(int *,int);
void heapIncreaseKey(int *,int,int);
void temp(int *,int *);

int j=0;

int main(){
  int i,k,S[MAX];
  char order[8];

  for(i=1;i<MAX;i++){
    scanf("%s",order);
    if(strcmp("insert",order)==0){
      scanf("%d",&k);
      maxHeapInsert(S,k);
    }

    else if(strcmp("extract",order)==0) printf("%d\n",heapExtractMax(S));

    else return 0;
  }
}

void maxHeapify(int *A,int i){
  int l,r,largest;

  l=i*2;
  r=i*2+1;

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

  if(r<=j&&A[r]>A[largest])
    largest=r;

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

int heapExtractMax(int *A){
  int max;

  if(j<1) return;

  max=A[1];
  A[1]=A[j];
  j--;
  maxHeapify(A,1);
  return max;
}

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

void heapIncreaseKey(int *A,int i,int key){
  if(key<A[i]) return;
  
  A[i]=key;

  while(i>1&&A[i/2]<A[i]){
    temp(&A[i],&A[i/2]);
    i=i/2;
  }
}
  
void temp(int *a,int *b){
  int temp;

  temp=*a;
  *a=*b;
  *b=temp;
}