def main

  heap = { }
  while str = gets
    str = str.split(/\s/)
    break if str[0] == "end"
    if str[0] == "insert"
      num = str[1].to_i
      heap[num] = 1
    else
      ans = heap.max[0]
      heap.delete(ans)
      puts ans
    end
  end
end

main