#include<stdio.h>
#include<string.h>
#define INT 2147483647
#define M 2000000
int size=0;


void maxHeapify(int *A,int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;
  if(l<=size && A[l]>A[i])
    largest=l;
  else
    largest=i;
  if(l<=size && A[r]>A[largest])
    largest = r;
  if(largest!=i){
    int tmp;
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(A,largest);
  }
}

void insert(int *A){
  scanf("%d",&A[++size]);
  int p=size;
  while(A[p/2]<A[p]){
    int tmp;
    tmp=A[p/2];
    A[p/2]=A[p];
    A[p]=tmp;
    p/=2;
  }
}

int extract(int *A){
  int max;
  max= A[1];
  A[1]=A[size--];
  maxHeapify(A,1);
  return max;
}

int main(){
  int heap[M];
  char order[8];
  heap[0]=INT;
  while(1){
    scanf("%s",order);
    if(!strcmp("end",order)) break;
    else if(!strcmp("insert",order)) insert(heap);
    else if(!strcmp("extract",order)) printf("%d\n",extract(heap));
  }
  return 0;
}

