#include <stdio.h>
#define MAX 2000001
#define INF 10000000
#define size 20

int H,A[MAX];

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

  //????????????????????????????????§???????????§????????????????????¶
  if(l<=H&&A[l]>A[i]) largest=1;
  else largest = i;
  if(r<=H&&A[r]>A[largest]) largest=r;

  if(largest!=i){
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}

int extract(){
  int max;
  if(H<1) return -INF;
  max=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return max;
}

void swap(int *a,int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}

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

void insert(int key){
  H++;
  A[H]=-INF;
  increaseKey(H,key);
}

int main(){
int key;
char str[size];

  while(1){
    scanf("%s",str);
    if(strcmp("end",str)/*str[0]=='e'&&str[1]=='n'*/) break;
    if(str[0]=='i'){
      scanf("%d",&key);
      insert(key);
    } else{
      printf("%d\n", extract());
    }
  }
  return 0;
}