Count open brackets for better hierarchy detection