


'''simple docstring'''



class 		_snake_case					:




					def __init__(      self							,							_lowerCamelCase):
								UpperCAmelCase__  :					List[str]        =     n
								UpperCAmelCase__  :					Any        =     [None] * self.n
								UpperCAmelCase__  :					List[Any]        =     0  # index of the first element
								UpperCAmelCase__  :					Union[str, Any]        =     0
								UpperCAmelCase__  :					List[str]        =     0




					def __len__(      self):
								return self.size




					def 				snake_case__						(      self):
								return self.size == 0




					def 				snake_case__						(      self):
								return False if self.is_empty() else self.array[self.front]




					def 				snake_case__						(      self							,							_lowerCamelCase):
								if self.size >= self.n:
											raise Exception("""QUEUE IS FULL""")

								UpperCAmelCase__  :					Dict        =     data
								UpperCAmelCase__  :					Optional[Any]        =     (self.rear + 1) % self.n
								self.size += 1
								return self




					def 				snake_case__						(      self):
								if self.size == 0:
											raise Exception("""UNDERFLOW""")

								UpperCAmelCase__  :					List[str]        =     self.array[self.front]
								UpperCAmelCase__  :					Any        =     None
								UpperCAmelCase__  :					Union[str, Any]        =     (self.front + 1) % self.n
								self.size -= 1
								return temp



'''simple docstring'''



import os







def     _UpperCamelCase      (		UpperCamelCase__ = "input.txt"					):

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

			UpperCAmelCase__  :					Optional[Any]        =     len(UpperCamelCase__					)
			UpperCAmelCase__  :					Any        =     len(matrix[0]					)

			UpperCAmelCase__  :					Optional[int]        =     [[-1 for _ in range(UpperCamelCase__					)] for _ in range(UpperCamelCase__					)]
			for i in range(UpperCamelCase__					):
						UpperCAmelCase__  :					Any        =     matrix[i][0]

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

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

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