#include <stdio.h>
#include <stdlib.h>

int N;
int H;
int arr[2000002];
int tmp = 0;

void maxHeapify(int i){
    int l = 2*i;
    int r = 2*i+1;
    int largest;
    if(l <= H && arr[l] > arr[i]){
        largest = l;
    }
    else largest = i;
    if(r <= H && arr[r] > arr[largest]){
        largest = r;
    }
    if(largest != i){
        tmp = arr[i];
        arr[i] = arr[largest];
        arr[largest] = tmp;
        maxHeapify(largest);
    }
}

void heapIncreaseKey(int i, int key) {
    arr[i] = key;
    while(i > 1 && arr[i/2] < arr[i]) {
    tmp = arr[i];
    arr[i] = arr[i/2];
    arr[i/2] = tmp;
    i = i/2;
    }
}

void maxHeapInsert(int key) {
    H++;
    arr[H] = -33333333;
    heapIncreaseKey(H, key);
}

int heapExtractMax() {
    int max = arr[1];
    arr[1] = arr[H];
    H--;
    maxHeapify(1);
    return max;
}

int main()
{
    int i;
    char cccc[20];
    int key;
    N = 0;
  while(scanf("%s", cccc)) {
    if(cccc[2] == 's') {
      scanf("%d", &key);
      maxHeapInsert(key);
    } else if(cccc[2] == 't') {
      printf("%d\n", heapExtractMax());
    } else {
      break;
    }
  }
  return 0;
    return 0;
}


