#include<stdio.h>

#define X 100000000

int n;
int A[2000000];
int Count();
void maxHeapify(int i);
void increaseKey(int n, int k);
void insert(int k);
int extractMax();

int main(){
  int i,n;
  char dist[20];
  for (i=1;i<=2000000;i++){
    scanf("%s",dist);
    if(dist[0]=='i'){
      scanf("%d",&n);
      insert(n);
    }
    else if(dist[1]=='x'){
      printf("%d\n",extractMax());
    }
    else if(dist[1]=='n'){
      break;
    }
  }
  return 0;
}

int Count(){
  int i;
  for(i=1;A[i]!=0;i++)
  return i;
}

void maxHeapify(int i){
  int left,right,large,tmp,k;
  left=2*i;
  right=2*i+1;
  if(left<=n&&A[left]>A[i]){
    large=left;
  }
  else large=i;
  if(right<=n&&A[right]>A[large]){
    large=right;
  }
  if(large!=i){
    tmp=A[i];
    A[i]=A[large];
    A[large]=tmp;
    maxHeapify(large);
  }
}

void increaseKey(int n,int k){
  int tmp;
  A[n]=k;
  while(n>1&&A[n/2]<A[n]){
    tmp=A[n];
    A[n]=A[n/2];
    A[n/2]=tmp;
    n/=2;
  }
}

void insert(int k){
  int i;
  n++;
  A[n]=-X;
  increaseKey(n,k);
}

int extractMax(){
  int i,max;
  maxHeapify(1);
  max=A[1];
  A[1]=A[n];
  n--;
  maxHeapify(1);
  return max;
}

