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