include<stdio.h>

#define MAX 2000000

int array,A[MAX+1];

void maxHeapify(int x){

  int l, r, t,max;

  l = 2 * x;

  r = 2 * x + 1;

  if ( l <= array && A[l] > A[x] )
    {
      max = l;
    }

  else max = x;

  if ( r <= array && A[r] > A[max] )
    {
      max = r;
    }
  if ( max != x )
    {
      t = A[x];
      A[x] = A[max];
      A[max] = t;

      maxHeapify(max);
    }
}

nt extract(){

  int num;

  if ( array < 1 ) return;

  num = A[1];

  A[1] = A[array--];

  maxHeapify(1);

  return num;

}


void increaseKey(int x, int key){

  int tmp;

if ( key < A[x] ) return;

  A[x] = key;

  while ( x > 1 && A[x/2] < A[x] ){

    tmp = A[x];
    A[x] = A[x/2];
    A[x/2] = tmp;

    x = x/2;
  }
}

void insert(int key){
  array++;
  A[array] = -1000000001;
  increaseKey(array, key);
}

int main(){

  int key;
  char moji[20];

  while(1){

    scanf("%s",moji);

    if ( moji[0] == 'i' )
      {
        scanf("%d", &key);

        insert(key);

      }
    else if ( strcmp(moji, "extract") == 0  )
      {
        printf("%d\n", extract());

      } else break;
  }
  return 0;
}