#include<stdio.h>
#include<string.h>
int A[2000000];
int cnt=0;
void insert(int i){
  int a;
  int tmp;
  cnt++;
  A[cnt] = i;
  a = cnt;
  while(a){
    if(A[a/2] < A[a]){
      //printf("a%d %d %d\n",a/2,A[a/2],A[a]);
      tmp = A[a];
      A[a] = A[a/2];
      A[a/2] = tmp;
      a/=2;
    }
    else break;
  }
}
void maxHeapify(int i){
  int l = i*2;
  int r = l+1;
  int largest;
  int tmp;
  if(l<=cnt && A[l]>A[i]){
    largest = l;
  }
  else largest = i;
  if(r<=cnt && A[r]>A[largest]){
    largest = r;
  }

  if(largest !=i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}
void extract(void){
  int tmp=A[1];
  printf("%d\n",tmp);
  A[1] = A[cnt];
  A[cnt--] = tmp;
  maxHeapify(1);
}
int main(){
  int i;
  char str[20];
  A[0]=1000000000;
  while(1){
    scanf("%s",str);
    if(!strcmp(str,"end")) break;
    if(str[0]=='i'){
      scanf("%d",&i);
      insert(i);
    }
    if(str[0]=='e'){
      extract();
    }
  }
  return 0;
}

