



import os






def        __lowerCAmelCase		(	__lowerCamelCase						:     str = "input.txt"						)	->    int:

					with open(os.path.join(os.path.dirname(__lowerCamelCase						)					, __lowerCamelCase						)						) as input_file:
										__lowerCAmelCase						 =[
										    [int(__lowerCamelCase						) for element in line.split(""","""						)]
										    for line in input_file.readlines()
										]

					__lowerCAmelCase						 =len(__lowerCamelCase						)
					__lowerCAmelCase						 =len(matrix[0]						)

					__lowerCAmelCase						 =[[-1 for _ in range(__lowerCamelCase						)] for _ in range(__lowerCamelCase						)]
					for i in range(__lowerCamelCase						):
										__lowerCAmelCase						 =matrix[i][0]

					for j in range(1					, __lowerCamelCase						):
										for i in range(__lowerCamelCase						):
															__lowerCAmelCase						 =minimal_path_sums[i][j - 1] + matrix[i][j]

										for i in range(1					, __lowerCamelCase						):
															__lowerCAmelCase						 =min(
															    minimal_path_sums[i][j]					, minimal_path_sums[i - 1][j] + matrix[i][j]						)

										for i in range(rows - 2					, -1					, -1						):
															__lowerCAmelCase						 =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() = }")









def        __lowerCAmelCase		(	__lowerCamelCase						:     int						)	->    bool:
					if number < 0:
										raise ValueError("""number must not be negative"""						)
					return number & (number - 1) == 0


if __name__ == "__main__":
				import doctest

				doctest.testmod()




