#include <stdio.h>
#include <string.h>
#include <limits.h>
#define N 2000000



int A[N],heap=0;

main()
{
  
  
  int a;
  char s[30];
  
 
  while(1){
    scanf("%s",s);
    if(strcmp(s,"end")==0){
      break;
    }
    
    if(s[0]=='i') {
      scanf("%d",&a);
      maxHeapInsert(a);
    }
    else {
      printf("%d\n",heapExtractMax());
    }
  }
  
  return 0;
  
}

int parent(int a)
{
  return a/2;
}

int left(int a)
{
  return 2*a;
}

int right(int a)
{
  return 2*a + 1;
}

int maxHeapify(int i)
{
  
  int l = left(i),r = right(i); 
  int largest;
  int tmp;
  
  
  if(l <= heap && A[l] > A[i]){
    largest = l;
  }
  else{
    largest = i;
  }
  
  if(r <= heap && A[r] > A[largest]){
    largest = r;
  }
  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}

int heapExtractMax()
{

  int max;

    if(heap < 1){
    return 0;
    }

  max = A[1];
  A[1] = A[heap];
  heap--;
  maxHeapify(1);
  return max;
}

void heapIncreaseKey(int i, int key)
{
  int tmp;
  
  if(key < A[i]){
    return;
  }
  
  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 maxHeapInsert(int key)
{
  
  heap++;
  A[heap] = INT_MIN;
  heapIncreaseKey(heap,key);
}