var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _parent(i) {
  return ~ ~(i / 2);
}
function _right(i) {
  return 2 * i + 1;
}
function _left(i) {
  return 2 * i;
}

var BinaryHeap = (function () {
  function BinaryHeap(comp) {
    _classCallCheck(this, BinaryHeap);

    this.comp = comp || function (a, b) {
      return a < b;
    };
    this.collection = [];
  }

  _createClass(BinaryHeap, [{
    key: "from",
    value: function from(array) {
      this.collection = array;
      for (var i = ~ ~(array.length / 2); i >= 0; --i) this.heapify(this.collection, i);
      return this;
    }
  }, {
    key: "toArray",
    value: function toArray() {
      return this.collection.sort(this.comp);
    }
  }, {
    key: "heapify",
    value: function heapify(arr, i) {
      var l = _left(i);
      var r = _right(i);
      var largest;

      if (l < arr.length && this.comp(arr[i], arr[l])) largest = l;else largest = i;
      if (r < arr.length && this.comp(arr[largest], arr[r])) largest = r;

      if (largest !== i) {
        var t = arr[i];
        arr[i] = arr[largest];
        arr[largest] = t;
        return this.heapify(arr, largest);
      }
    }
  }, {
    key: "push",
    value: function push(value) {
      this.collection.push(value);
      var arr = this.collection;
      for (var i = arr.length - 1; i > 0 && this.comp(arr[_parent(i)], arr[i]); i = _parent(i)) {
        var tmp = arr[i];
        arr[i] = arr[_parent(i)];
        arr[_parent(i)] = tmp;
      }
      return this;
    }
  }, {
    key: "top",
    value: function top() {
      return this.collection[0];
    }
  }, {
    key: "pop",
    value: function pop() {
      var ret = this.collection[0];
      if (1 < this.collection.length) {
        this.collection[0] = this.collection.pop();
        this.heapify(this.collection, 0);
      } else {
        this.collection.pop();
      }
      return ret;
    }
  }]);

  return BinaryHeap;
})();


var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

(function solve(lines){
  var pq = new BinaryHeap();
  lines.forEach(function(line){
    words = line.split(" ");
    if(words[0] === "insert"){
      pq.push(parseInt(words[1]));
    }else if(words[0] === "extract"){
      console.log(pq.pop());
    }
  });
})(lines);