





"""simple docstring"""




import os





def 						UpperCAmelCase__		(     _UpperCAmelCase = "input.txt"					):






  """simple docstring"""





  with open(os.path.join(os.path.dirname(_UpperCAmelCase					) ,					_UpperCAmelCase					)					) as input_file:
    A_  :       Dict										=  [
        [int(_UpperCAmelCase					) for element in line.split(','					)]
        for line in input_file.readlines()
    ]

  A_  :       List[Any]										=  len(_UpperCAmelCase					)
  A_  :       Optional[int]										=  len(matrix[0]					)

  A_  :       List[Any]										=  [[-1 for _ in range(_UpperCAmelCase					)] for _ in range(_UpperCAmelCase					)]
  for i in range(_UpperCAmelCase					):
    A_  :       Optional[int]										=  matrix[i][0]

  for j in range(1 ,					_UpperCAmelCase					):
    for i in range(_UpperCAmelCase					):
      A_  :       Optional[int]										=  minimal_path_sums[i][j - 1] + matrix[i][j]

    for i in range(1 ,					_UpperCAmelCase					):
      A_  :       Any										=  min(
          minimal_path_sums[i][j] ,					minimal_path_sums[i - 1][j] + matrix[i][j]					)

    for i in range(rows - 2 ,					-1 ,					-1					):
      A_  :       Tuple										=  min(
          minimal_path_sums[i][j] ,					minimal_path_sums[i + 1][j] + matrix[i][j]					)

  return min(minimal_path_sums_row[-1] for minimal_path_sums_row in minimal_path_sums					)


if __name__ == "__main__":
   print(F"{solution() = }")






"""simple docstring"""




import os

# Precomputes a list of the 100 first triangular numbers
lowerCamelCase_     :						List[str]						=					[int(0.5 * n * (n + 1)) for n in range(1, 1_01)]





def 						UpperCAmelCase__		(     ):






  """simple docstring"""





  A_  :       Union[str, Any]										=  os.path.dirname(os.path.realpath(_UpperCAmelCase					)					)
  A_  :       Tuple										=  os.path.join(_UpperCAmelCase ,					'words.txt'					)

  A_  :       List[Any]										=  ''
  with open(_UpperCAmelCase					) as f:
    A_  :       int										=  f.readline()

  A_  :       Optional[Any]										=  [word.strip('"'					) for word in words.strip('\r\n'					).split(','					)]
  A_  :       Dict										=  [
      word
      for word in [sum(ord(_UpperCAmelCase					) - 64 for x in word					) for word in words]
      if word in TRIANGULAR_NUMBERS
  ]
  return len(_UpperCAmelCase					)


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