#include<stdio.h>
#include<string.h>

#define MAX 2000000
#define INF 1000000
int size;
int S[MAX];

void maxHeapify(int i){
  int l=2*i;
  int r=2*i+1;
  int largest=0,tmp;

  if(l<=size && S[l]>S[i]){
    largest=l;
  }else{
    largest=i;
  }

  if(r<=size && S[r]>S[largest]){
    largest=r;
  }

  if(largest!=i){
    tmp=S[i];
    S[i]=S[largest];
    S[largest]=tmp;
    maxHeapify(largest);
  }
}

int extractMax(){
  int max;

  max=S[1];
  S[1]=S[size];
  size--;
  maxHeapify(1);

  return max;
}

void heapIncreaseKey(int k){
  int i=size;
  int tmp;

  S[i]=k;
  while(i>1 && S[i/2]<S[i]){
    tmp=S[i];
    S[i]=S[i/2];
    S[i/2]=tmp;
    i=i/2;
  }
}

void insert(int k){
  size+=1;
  S[size]=-INF;
  heapIncreaseKey(k);
}

int main(){
  char c[10];
  int k;

  while(1){
    scanf("%s",c);
    if(strcmp(c,"insert")==0){
      scanf("%d",&k);
      insert(k);
    }else if(strcmp(c,"extract")==0){
      printf("%d\n",extractMax());
    }else if(strcmp(c,"end")==0){
      break;
    }
  }

  return 0;
}