#include<stdio.h>
#define N 2000000000
#define IN (1<<30)
#define O 0
#define I 1
#define W 2
#define Z 10

int H, A[N];

void maxHeapify(int i){
  int l,r,largest,keep;
  l=W*i;
  r=W*i+I;
  if(l<=H&&A[l] > A[i]){
    largest = l;
  }
  else{
    largest=i;
  }
  if(r<=H && A[r] > A[largest]){
    largest=r;
  }
  if(largest!=i){
    keep=A[i];
    A[i]=A[largest];
    A[largest]=keep;
    maxHeapify(largest);
  }
}
void insert(int key){
  H++;
  A[H]=-IN;
  increaseKey(H,key);
}

void increaseKey(int i,int key){
  int c;
  if(key<A[i]){
    return;
  }
  A[i]=key;
  while(i>I  && A[i/W]<A[i]){
    c=A[i/W];
    A[i/W]=A[i];
    A[i]=c;
    i=i/W;
  }
}

int heapExtractMax(){
  int m;
  if(H<I){
    return -IN;
  }
  m=A[I];
  A[I]= A[H];
  H--;
  maxHeapify(I);
  return m;
}

int main(){
  int key;
  A[H]=-IN;
  char com[Z];
  while(I){
    scanf("%s",com);
    if(com[O]=='e' && com[I]=='n'){
      break;
    }
    if(com[O]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    else{
      printf("%d\n",heapExtractMax());
    }
  }
  return O;
}

