
import math
from itertools import permutations




def     a						(							snake_case__: int ):


				'''simple docstring'''

				if 1 < number < 4:
								# 2 and 3 are primes
								return True
				elif number < 2 or number % 2 == 0 or number % 3 == 0:
								# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
								return False

				# All primes number are in format of 6k +/- 1
				for i in range(5						,       int(math.sqrt(snake_case__ ) + 1 )						,       6 ):
								if number % i == 0 or number % (i + 2) == 0:
												return False
				return True




def     a						(							snake_case__: int						,       snake_case__: list ):


				'''simple docstring'''
				lowercase_  ,     lowercase_					  = 0, len(snake_case__ ) - 1
				while left <= right:
								lowercase_					  = (left + right) // 2
								if prime_list[middle] == target:
												return True
								elif prime_list[middle] < target:
												lowercase_					  = middle + 1
								else:
												lowercase_					  = middle - 1

				return False




def     a						(							):


				'''simple docstring'''
				lowercase_					  = [n for n in range(1_001						,       10_000						,       2 ) if is_prime(snake_case__ )]
				lowercase_					  = []

				for number in prime_list:
								lowercase_					  = []

								for prime_member in permutations(list(str(snake_case__ ) ) ):
												lowercase_					  = int(''''''.join(snake_case__ ) )

												if prime % 2 == 0:
																continue

												if search(snake_case__						,       snake_case__ ):
																tmp_numbers.append(snake_case__ )

								tmp_numbers.sort()
								if len(snake_case__ ) >= 3:
												candidates.append(snake_case__ )

				lowercase_					  = []
				for candidate in candidates:
								lowercase_					  = len(snake_case__ )
								lowercase_					  = False

								for i in range(snake_case__ ):
												for j in range(i + 1						,       snake_case__ ):
																for k in range(j + 1						,       snake_case__ ):
																				if (
																				    abs(candidate[i] - candidate[j] )
																				    == abs(candidate[j] - candidate[k] )
																				    and len({candidate[i], candidate[j], candidate[k]} ) == 3
																				):
																								passed.append(
																								    sorted([candidate[i], candidate[j], candidate[k]] ) )
																								lowercase_					  = True

																				if found:
																								break
																if found:
																				break
												if found:
																break

				lowercase_					  = set()
				for seq in passed:
								answer.add(''''''.join([str(snake_case__ ) for i in seq] ) )

				return max(int(snake_case__ ) for x in answer )


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






from __future__ import annotations

__a        = 'Alexander Joslin'




def     a						(							snake_case__: int ):


				'''simple docstring'''

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

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

				# starting position
				lowercase_					  = 0
				for i in range(1						,       snake_case__ ):
								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()




