#include<stdio.h>
#define N 2000000

int A[N],a=0;

void increase(int i, int n){
  int temp;
  if(n < A[i]){
    return;
  }
  A[i] = n;
  while(i > 1 && A[i/2] < A[i]){
    temp = A[i];
    A[i] = A[i/2];
    A[i/2] = temp;
    i = i/2;
  }
}

void insert(int n){
  a++;
  A[a] = -1000000000;
  increase(a,n);
}

void maxheap(int i){
  int l,r,temp2,largest;
  l = 2 * i;
  r = 2 * i + 1;
  if(A[l] > A[i] && l <= a){
    largest = l;
  }else{
    largest = i;
  }
  if(A[r] > A[largest] && r <= a){
    largest = r;
  }

  if(largest != i){
    temp2 = A[i];
    A[i] = A[largest];
    A[largest] = temp2;
    maxheap(largest);
  }
}

int extract(){
  int m;
  if(a < 1){
    return -1000000000;
  }
  m = A[1];
  A[1] = A[a];
  a--;
  maxheap(1);
  return m;
}
  
int main(){
  int n;
  char com[20];
  while(1){
    scanf("%s",com);
    if(com[0] == 'e' && com[1] == 'n'){
      break;
    }
    if(com[0] == 'i'){
      scanf("%d",&n);
      insert(n);
    }else{
      printf("%d\n",extract());
    }
  }
  return 0;
}

