#include<stdio.h>
#define MAX 2000000

int arr, A[MAX+1];

void maxHeapify(int x){

  int l, r, t, max;

  l = 2 * x;

  r = 2 * x + 1;

  if ( l <= arr && A[l] > A[x] ) max = l;

  else max = x;

  if ( r <= arr && A[r] > A[max] ) max = r;

  if ( max != x ){

    t = A[x];

    A[x] = A[max];

    A[max] = t;

    maxHeapify(max);

  }

}


int extract(){

  int ans;

  if ( arr < 1 ) return;

  ans = A[1];

  A[1] = A[arr--];

  maxHeapify(1);

  return ans;

}

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){

  arr++;

  A[arr] = -1000000001;

  increaseKey(arr, key);

}


int main(){
  int key;
  char array[20];
  while(1){
    scanf("%s", array);
    if ( array[0] == 'i' ){
      scanf("%d", &key);
      insert(key);
    } else if ( strcmp(array, "extract") == 0  ){
      printf("%d\n", extract());
    } else break;
  }

  return 0;

}