


"""simple docstring"""


import os







def  __snake_case       (   UpperCamelCase__ = "input.txt"	)      ->		int:







		"""simple docstring"""





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

		A					       = len(UpperCamelCase__	)
		A					       = len(matrix[0]	)

		A					       = [[-1 for _ in range(UpperCamelCase__	)] for _ in range(UpperCamelCase__	)]
		for i in range(UpperCamelCase__	):
				A					       = matrix[i][0]

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

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

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


def  __snake_case       (   )      ->		int:







		"""simple docstring"""





		return 1







def  __snake_case       (   UpperCamelCase__	)      ->		int:







		"""simple docstring"""





		return 0 if x < 0 else two_pence(x - 2	) + one_pence()







def  __snake_case       (   UpperCamelCase__	)      ->		int:







		"""simple docstring"""





		return 0 if x < 0 else five_pence(x - 5	) + two_pence(UpperCamelCase__	)







def  __snake_case       (   UpperCamelCase__	)      ->		int:







		"""simple docstring"""





		return 0 if x < 0 else ten_pence(x - 10	) + five_pence(UpperCamelCase__	)







def  __snake_case       (   UpperCamelCase__	)      ->		int:







		"""simple docstring"""





		return 0 if x < 0 else twenty_pence(x - 20	) + ten_pence(UpperCamelCase__	)







def  __snake_case       (   UpperCamelCase__	)      ->		int:







		"""simple docstring"""





		return 0 if x < 0 else fifty_pence(x - 50	) + twenty_pence(UpperCamelCase__	)







def  __snake_case       (   UpperCamelCase__	)      ->		int:







		"""simple docstring"""





		return 0 if x < 0 else one_pound(x - 100	) + fifty_pence(UpperCamelCase__	)







def  __snake_case       (   UpperCamelCase__	)      ->		int:







		"""simple docstring"""





		return 0 if x < 0 else two_pound(x - 200	) + one_pound(UpperCamelCase__	)







def  __snake_case       (   UpperCamelCase__ = 200	)      ->		int:







		"""simple docstring"""





		return two_pound(UpperCamelCase__	)


if __name__ == "__main__":
	print(solution(int(input().strip())))





