import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.container;
 
void main()
{
  auto ai = new PriorityQueue!int(2_0000_000);
 
  for (;;) {
    auto rd = readln.chomp.splitter(' '), cmd = rd.front;
    switch (cmd) {
    case "insert":
      rd.popFront;
      ai.insert(rd.front.to!int);
      break;
    case "extract":
      writeln(ai.remove);
      break;
    case "end":
      return;
    default:
      assert(0);
    }
  }
}

class PriorityQueue(T)
{
  T[] buf;
  size_t s, t;

  this(size_t capacity)
  {
    buf = new T[](capacity);
    s = capacity - 1;
    t = 1;
  }

  void insert(T val)
  {
    buf[s--] = val;
    ++t;
    maxHeapify(buf[s..s+t], t, 1);
  }

  T remove()
  {
    T val = buf[s+1];
    buf[s+1] = buf[s+t-1];
    --t;
    maxHeapify(buf[s..s+t], t, 1);
    return val;
  }

  void maxHeapify(int[] ai, size_t t, size_t i)
  {
    auto l = i * 2, r = l + 1;
    size_t largest;

    if (l < t && ai[l] > ai[i])
      largest = l;
    else
      largest = i;
    if (r < t && ai[r] > ai[largest])
      largest = r;

    if (largest != i) {
      swap(ai[i], ai[largest]);
      maxHeapify(ai, t, largest);
    }
  }
}