"""simple docstring"""






import os


def 			UpperCAmelCase__       (				lowerCAmelCase__     :List[str] = "matrix.txt"		) ->    int:
      '''simple docstring'''


      with open(os.path.join(os.path.dirname(SCREAMING_SNAKE_CASE_		)					,		SCREAMING_SNAKE_CASE_		)		) as in_file:
            lowercase														=	in_file.read()

      lowercase														=	[[int(SCREAMING_SNAKE_CASE_		) for cell in row.split(""","""		)] for row in data.strip().splitlines()]
      lowercase														=	[[0 for cell in row] for row in grid]
      lowercase														=	len(grid[0]		)

      lowercase														=	[[0 for i in range(SCREAMING_SNAKE_CASE_		)] for j in range(SCREAMING_SNAKE_CASE_		)]
      lowercase														=	grid[0][0]
      for i in range(1					,		SCREAMING_SNAKE_CASE_		):
            lowercase														=	grid[0][i] + dp[0][i - 1]
      for i in range(1					,		SCREAMING_SNAKE_CASE_		):
            lowercase														=	grid[i][0] + dp[i - 1][0]

      for i in range(1					,		SCREAMING_SNAKE_CASE_		):
            for j in range(1					,		SCREAMING_SNAKE_CASE_		):
                  lowercase														=	grid[i][j] + min(dp[i - 1][j]					,		dp[i][j - 1]		)

      return dp[-1][-1]


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





class      A__							:






				def __init__(						self					:      Optional[Any]    ,     a					:      list   ):






							'''simple docstring'''







							lowerCAmelCase__      :      Dict         =		set_counts
							lowerCAmelCase__      :      str         =		max(a   )
							lowerCAmelCase__      :      Any         =		len(a   )
							lowerCAmelCase__      :      List[str]         =		[1] * num_sets
							lowerCAmelCase__      :      Dict         =		list(range(a   )   )






				def 							_lowerCamelCase		(						self					:      Dict    ,     a					:      int    ,     a					:      int   ):






							'''simple docstring'''







							lowerCAmelCase__      :      Optional[Any]         =		self.get_parent(a   )
							lowerCAmelCase__      :      Tuple         =		self.get_parent(a   )

							if src_parent == dst_parent:
										return False

							if self.ranks[dst_parent] >= self.ranks[src_parent]:
										self.set_counts[dst_parent] += self.set_counts[src_parent]
										lowerCAmelCase__      :      Tuple         =		0
										lowerCAmelCase__      :      str         =		dst_parent
										if self.ranks[dst_parent] == self.ranks[src_parent]:
													self.ranks[dst_parent] += 1
										lowerCAmelCase__      :      List[Any]         =		self.set_counts[dst_parent]
							else:
										self.set_counts[src_parent] += self.set_counts[dst_parent]
										lowerCAmelCase__      :      Optional[int]         =		0
										lowerCAmelCase__      :      Tuple         =		src_parent
										lowerCAmelCase__      :      Optional[int]         =		self.set_counts[src_parent]

							lowerCAmelCase__      :      Optional[Any]         =		max(self.max_set    ,     a   )
							return True






				def 							_lowerCamelCase		(						self					:      Any    ,     a					:      int   ):






							'''simple docstring'''







							if self.parents[disj_set] == disj_set:
										return disj_set
							lowerCAmelCase__      :      Tuple         =		self.get_parent(self.parents[disj_set]   )
							return self.parents[disj_set]