#include<stdio.h>

int que[250];
int count=0;

void insert(int *que,int t){
  int i = count;
  if(i==0)que[i]=t;
  else {
    que[i]=t;
    for(i=count;i>0;i--){
      if(que[i-1]<que[i]){
	que[i]=que[i-1];
	que[i-1]=t;
      }
    }
  }
}

void extractMax(int *que){
  int j;
  int i=count;
  printf("%d\n",que[0]);
  for(j=0;j<count;j++){
    que[j]=que[j+1];
  }
  count--;
}
  

int main(){
  char *pp;
  int t;

  while(1){
    scanf(" %s",pp);

    if(pp[2]=='s'){
      scanf("%d",&t);
      insert(que,t);
      count++;
    }
    else if(pp[2]=='t'){
      extractMax(que);
    }
    else break;
  }
  return 0;
}

