

from __future__ import annotations

A_:      int        =			"""Alexander Joslin"""


def 					__lowerCAmelCase			(  _A					):



							"""simple docstring"""


							if number <= 0:
														_lowercase				=	f'''n must be greater than 0. Got n = {number}'''
														raise ValueError(_A					)

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

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


if __name__ == "__main__":
				import doctest

				doctest.testmod()



def 					__lowerCAmelCase			(  _A = 998_001					):



							"""simple docstring"""


							_lowercase				=	0
							for i in range(999 ,99 ,-1					):  # 3 digit numbers range from 999 down to 100
														for j in range(999 ,99 ,-1					):
																					_lowercase				=	str(i * j					)
																					if product_string == product_string[::-1] and i * j < n:
																												_lowercase				=	max(_A ,i * j					)
							return answer


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


