def main

  heap = { }
  while str = gets
    str = str.rstrip
    if str == "extract"
      ans = heap.max
      puts "#{ans[0]}"
      heap.delete_if { |key, val| key == ans[0] and val == ans[1]}
    elsif str == "end"
      break
    else
      op, num = str.split(/\s/)
      num = num.to_i
      heap[num] = true
    end
  end
end

main