#include <stdio.h>
#include <string.h>
#define MAX 200000001
#define I 2000000001

long long A[MAX];
int n;

void maxHeapify(int);
void insert(int);
void increasekey(int,int);
int extract();


int main(){
  int i,key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(strcmp(com,"end")==0) break;
    if(strcmp(com,"insert")==0){
      scanf("%d",&key);
      insert(key);
    }
    else{
      //printf("\n");
      printf("%d",extract());
    }
  }
  printf("\n");
  return 0;
}

void maxHeapify(int i){
  int large;
  int temp;

  if(2*i<=n && A[2*i]>A[i]) large=2*i;
  else large=i;
  if(2*i+1<=n && A[2*i+1]>A[large]) large=2*i+1;

  if(large!=i){
    temp=A[i];
    A[i]=A[large];
    A[large]=temp;
    maxHeapify(large);
  }
}

void insert(int key){
  n++;
  A[n]=-I;
  increasekey(n,key);
}

void increasekey(int i,int key){
  int temp;
  if(key<A[i]) return;
  A[i]=key;
  while(i>1 && A[i/2]<A[i]){
    temp=A[i/2];
    A[i/2]=A[i];
    A[i]=temp;
    i=i/2;
  }
}

int extract(){
  int large;
  if(n<1) return -I;
  large=A[1];
  A[1]=A[n--];
  maxHeapify(1);
  return large;
}