



"""simple docstring"""


import math
from itertools import permutations

def 				_lowerCAmelCase   (     lowercase_		):

						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(lowercase_		) + 1		)	,			6		):
												if number % i == 0 or number % (i + 2) == 0:
																		return False
						return True

def 				_lowerCAmelCase   (     lowercase_	,			lowercase_		):
						UpperCAmelCase   ,					UpperCAmelCase    =				0, len(lowercase_		) - 1
						while left <= right:
												UpperCAmelCase    =				(left + right) // 2
												if prime_list[middle] == target:
																		return True
												elif prime_list[middle] < target:
																		UpperCAmelCase    =				middle + 1
												else:
																		UpperCAmelCase    =				middle - 1

						return False

def 				_lowerCAmelCase   (     ):
						UpperCAmelCase    =				[n for n in range(1001	,			10000	,			2		) if is_prime(lowercase_		)]
						UpperCAmelCase    =				[]

						for number in prime_list:
												UpperCAmelCase    =				[]

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

																		if prime % 2 == 0:
																								continue

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

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

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

												for i in range(lowercase_		):
																		for j in range(i + 1	,			lowercase_		):
																								for k in range(j + 1	,			lowercase_		):
																														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]]		)		)
																																				UpperCAmelCase    =				True

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

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

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


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










"""simple docstring"""


from dataclasses import dataclass
from typing import Callable, Optional

import datasets







@dataclass
class    A_    (  datasets.BuilderConfig       ):



						"""simple docstring"""
						__UpperCamelCase	       =							None
						__UpperCamelCase	       =							None
						__UpperCamelCase	       =							None






						def 			UpperCAmelCase__  (      self				:str      )       ->    Optional[Any]:
												assert self.generator is not None, "generator must be specified"

												if self.gen_kwargs is None:
																		UpperCAmelCase    =				{}







class    A_    (  datasets.GeneratorBasedBuilder       ):



						"""simple docstring"""
						__UpperCamelCase	       =							GeneratorConfig






						def 			UpperCAmelCase__  (      self				:Union[str, Any]      )       ->    str:
												return datasets.DatasetInfo(features=self.config.features      )






						def 			UpperCAmelCase__  (      self				:List[Any]     ,						lowercase_				:List[Any]      )       ->    Union[str, Any]:
												return [datasets.SplitGenerator(name=datasets.Split.TRAIN     ,						gen_kwargs=self.config.gen_kwargs      )]






						def 			UpperCAmelCase__  (      self				:Optional[int]     ,						**lowercase_				:Dict      )       ->    str:
												for idx, ex in enumerate(self.config.generator(**lowercase_      )      ):
																		yield idx, ex





