


'''simple docstring'''







import os


def      SCREAMING_SNAKE_CASE_ (  )  ->      Union[str, Any]:
       _a   :			str					 =0
       _a   :			int					 =0
       with open(os.path.dirname(_UpperCAmelCase  ) + """/p022_names.txt"""  ) as file:
              _a   :			str					 =str(file.readlines()[0]  )
              _a   :			Optional[Any]					 =name.replace("""\""""   ,""""""  ).split(""","""  )

       name.sort()
       for i in range(len(_UpperCAmelCase  )  ):
              for j in name[i]:
                     temp_sum += ord(_UpperCAmelCase  ) - ord("""A"""  ) + 1
              total_sum += (i + 1) * temp_sum
              _a   :			int					 =0
       return total_sum


if __name__ == "__main__":
   print(solution())






'''simple docstring'''







import math


def      SCREAMING_SNAKE_CASE_ (  _UpperCAmelCase     :     int  )  ->      int:
       return sum(int(_UpperCAmelCase  ) for digit in str(_UpperCAmelCase  )  )


def      SCREAMING_SNAKE_CASE_ (  _UpperCAmelCase     :     int = 30  )  ->      int:
       _a   :			List[Any]					 =[]
       for digit in range(2   ,100  ):
              for power in range(2   ,100  ):
                     _a   :			Optional[Any]					 =int(math.pow(_UpperCAmelCase   ,_UpperCAmelCase  )  )
                     if digit == digit_sum(_UpperCAmelCase  ):
                            digit_to_powers.append(_UpperCAmelCase  )

       digit_to_powers.sort()
       return digit_to_powers[n - 1]


if __name__ == "__main__":
   print(solution())


