/* C Priority Queue */
#include<stdio.h>

int S[2000001];
int heap_size=0;

int parent(int i);
int left(int i);
int right(int i);

void maxHeapInsert(int A[],int key);
void heapIncreaseKey(int A[], int i, int key);
int heapExtractMax(int A[]);
void maxHeapify(int A[],int i);

int main(){
  char com[7];
  int k;
  int i;

  while(1){
    scanf("%s",com);
    if(com[2]=='s'){       /*insert*/
      scanf("%d",&k);
      maxHeapInsert(S,k);
    }else if(com[2]=='t'){ /*extract*/
      printf("%d\n",heapExtractMax(S));
    }else{                 /*end*/
      break;
    }
  }
  return 0;
}

void maxHeapInsert(int A[],int key){
  int temp;
  heap_size=heap_size+1;
  A[heap_size]=-1; /*0<=key<=2,000,000,000*/
  heapIncreaseKey(A, heap_size, key);
}
void heapIncreaseKey(int A[], int i, int key){
  int temp;
  if(key<A[i]){
    fprintf(stderr,"new key is smaller than current key\n"); 
  }
  A[i]=key;
  while(i>1&&A[parent(i)]<A[i]){
    temp=A[i];
    A[i]=A[parent(i)];
    A[parent(i)]=temp;
    i=parent(i);
  }
}

int heapExtractMax(int A[]){
  int max;
  if(heap_size<1){
    fprintf(stderr,"heap underflow\n");
  }
  max=A[1];
  A[1]=A[heap_size];
  heap_size=heap_size-1;
  maxHeapify(A,1);
  return max;
}

void maxHeapify(int A[],int i){
  int temp;
  int l,r,largest;
  l=left(i);
  r=right(i);

  if(l<=heap_size&&A[l]>A[i]){
    largest=l;
  }else{
    largest=i;
  }
  if(r<=heap_size&&A[r]>A[largest]){
    largest=r;
  }
  if(largest!=i){
    temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    maxHeapify(A, largest);
  }
}

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