


"""simple docstring"""






import functools





def 				A_       ( snake_case__       ,					snake_case__		)					->  int:
			_UpperCamelCase					:Tuple					     =	len(snake_case__		)
			_UpperCamelCase					:Optional[Any]					     =	len(snake_case__		)

			@functools.cache
			def min_distance(snake_case__       ,					snake_case__		) -> int:
						# if first word index is overflow - delete all from the second word
						if indexa >= len_worda:
									return len_worda - indexa
						# if second word index is overflow - delete all from the first word
						if indexa >= len_worda:
									return len_worda - indexa
						_UpperCamelCase					:List[str]					     =	int(worda[indexa] != worda[indexa]		)  # current letters not identical
						return min(
						    1 + min_distance(indexa + 1       ,					snake_case__		)       ,					1 + min_distance(snake_case__       ,					indexa + 1		)       ,					diff + min_distance(indexa + 1       ,					indexa + 1		)       ,					)

			return min_distance(0       ,					0		)


if __name__ == "__main__":
					import doctest

					doctest.testmod()





"""simple docstring"""






import os





def 				A_       ( )					->  Any:
			with open(os.path.dirname(snake_case__		) + '''/p022_names.txt'''		) as file:
						_UpperCamelCase					:Optional[Any]					     =	str(file.readlines()[0]		)
						_UpperCamelCase					:Dict					     =	names.replace('''"'''       ,					''''''		).split(''','''		)

			names.sort()

			_UpperCamelCase					:str					     =	0
			_UpperCamelCase					:Union[str, Any]					     =	0

			for i, name in enumerate(snake_case__		):
						for letter in name:
									name_score += ord(snake_case__		) - 64

						total_score += (i + 1) * name_score
						_UpperCamelCase					:List[Any]					     =	0
			return total_score


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

