#include<stdio.h>
#include<string.h>
#define N 2000000
#define INF 50000000

int H,a[N+1];

void maxh(int);
void swap(int *,int *);
int extract();
void incrk(int,int);
void insert(int);

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

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

  }

}

void maxH(int i){
  int l,r,b;
  l=2*i;
  r=2*i+1;
    if(l<=H&&a[l] >a[i]) b =l;
    else b = i;

    if(r<=H&&a[r]>a[b]) b =r;
  if(b!=i){
    swap(&a[i],&a[b]);
    maxH(b);
    
  }
}

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

int extract(){
  int mv;
  if(H<1)return -INF;
  mv = a[1];
  a[1] = a[H--];
  maxH(1);
  return mv;

}

void incrk(int i,int k){
  if(k<a[i]) return;
  a[i]=k;
  while(i>1&&a[i/2]<a[i]){
    swap(&a[i],&a[i/2]);
    i=i/2;
  }
}

void insert(int k){

  H++;
  a[H]= -INF;
  incrk(H,k);

}

