#include<stdio.h>
#include<stdlib.h>
#define N 2000000
int n;
void heapIncreaseKey(int [],int,int);
int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}

void maxHeapify(int A[], int i){
  int lar;
  int le,ri;
  int tmp;
  le = left(i);
  ri = right(i);
  
  if(n>=le && A[le]>A[i])lar=le;
  else lar=i;
  
  if(n>=ri && A[ri]>A[lar]) lar=ri;
    
    if(lar != i){
      tmp=A[i];
      A[i]=A[lar];
      A[lar]=tmp;
      maxHeapify(A,lar);
    }
    
}

void buildMaxHeap(int A[]){
  int i;
  for(i=n/2;i>=1;i--){
    maxHeapify(A, i);
  }
}

void maxHeapInsert(int A[],int key){
  n=n+1;
  A[n]=-2147483647;
  heapIncreaseKey(A,n,key);
  
}

void heapIncreaseKey(int A[],int i,int key){
  int tmp;
  if(key < A[i])exit(1);
  A[i]=key;
  while(i>1 && A[parent(i)]<A[i]){
    tmp=A[i];
    A[i]=A[parent(i)];
    A[parent(i)]=tmp;
    i=parent(i);
  }
}

int heapExtractMax(int A[]){
  int max;
  if(n<1)exit(5);
  max=A[1];
  A[1]=A[n];
  n=n-1;
  maxHeapify(A,1);
  return max;
}

int main(void){
  int heap[N];
  int k;
  char c[20];
  while(1){
    scanf("%s",c);
    if( c[0] == 'i'){
      scanf("%d",&k);
      maxHeapInsert(heap, k);
    }else if( c[0] == 'e' && c[1] == 'x'){
      printf("%d\n",heapExtractMax(heap));
    }else break;       
  }
  return 0;
}