





"""simple docstring"""




from __future__ import annotations





def 		UpperCAmelCase__						(	_UpperCAmelCase   ):






  """simple docstring"""





  A_    :			Union[str, Any]									=    [0] * max_one

  for i in range(0					,   _UpperCAmelCase   ):
    A_    :			str									=    i

  for i in range(2					,   _UpperCAmelCase   ):
    if totients[i] == i:
      for j in range(_UpperCAmelCase					,   _UpperCAmelCase					,   _UpperCAmelCase   ):
        totients[j] -= totients[j] // i

  return totients





def 		UpperCAmelCase__						(	_UpperCAmelCase					,   _UpperCAmelCase   ):






  """simple docstring"""





  return sorted(str(_UpperCAmelCase   )   ) == sorted(str(_UpperCAmelCase   )   )





def 		UpperCAmelCase__						(	_UpperCAmelCase = 10000000   ):






  """simple docstring"""





  A_    :			Any									=    1  # i
  A_    :			Optional[Any]									=    0  # φ(i)
  A_    :			Any									=    get_totients(max_n + 1   )

  for i in range(2					,   max_n + 1   ):
    A_    :			str									=    totients[i]

    if i * min_denominator < min_numerator * t and has_same_digits(_UpperCAmelCase					,   _UpperCAmelCase   ):
      A_    :			Tuple									=    i
      A_    :			Union[str, Any]									=    t

  return min_numerator


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




def    UpperCAmelCase					(  lowercase__						:					int = 998001	):



			'''simple docstring'''





			for number in range(n - 1				,					9999				,					-1	):
						a__					=  str(lowercase__	)

						# checks whether 'str_number' is a palindrome.
						if str_number == str_number[::-1]:
									a__					=  999

									# if 'number' is a product of two 3-digit numbers
									# then number is the answer otherwise fetch next number.
									while divisor != 99:
												if (number % divisor == 0) and (len(str(number // divisor	)	) == 3.0):
															return number
												divisor -= 1
			raise ValueError("""That number is larger than our acceptable range."""	)


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

