





"""simple docstring"""




from __future__ import annotations

_a									=				'''Alexander Joslin'''





def lowerCAmelCase__(__snake_case							)    ->				int:







	'''simple docstring'''







	if number <= 0:
		lowerCamelCase__        =		F'n must be greater than 0. Got n = {number}'
		raise ValueError(__snake_case							)

	lowerCamelCase__        =		[number + 1] * (number + 1)

	# starting position
	lowerCamelCase__        =		0
	for i in range(1	,__snake_case							):
		lowerCamelCase__        =		min(table[i + 1]	,table[i] + 1							)
		# check if out of bounds
		if i * 2 <= number:
			lowerCamelCase__        =		min(table[i * 2]	,table[i] + 1							)
		# check if out of bounds
		if i * 3 <= number:
			lowerCamelCase__        =		min(table[i * 3]	,table[i] + 1							)
	return table[number]


if __name__ == "__main__":
			import doctest

			doctest.testmod()










import os





def lowerCAmelCase__()    ->				Optional[Any]:







	'''simple docstring'''







	lowerCamelCase__        =		os.path.dirname(os.path.realpath(__snake_case							)							)
	lowerCamelCase__        =		os.path.join(__snake_case	,'''triangle.txt'''							)

	with open(__snake_case							) as f:
		lowerCamelCase__        =		f.readlines()

	lowerCamelCase__        =		[[int(__snake_case							) for y in x.rstrip('''\r\n'''							).split(''' '''							)] for x in triangle]

	for i in range(1	,len(__snake_case							)							):
		for j in range(len(a[i]							)							):
			lowerCamelCase__        =		a[i - 1][j] if j != len(a[i - 1]							) else 0
			lowerCamelCase__        =		a[i - 1][j - 1] if j > 0 else 0
			a[i][j] += max(__snake_case	,__snake_case							)
	return max(a[-1]							)


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



