


'''simple docstring'''



from hashlib import mda, shaaaa

A__		: Dict												=  (shaaaa, mda)





class        UpperCAmelCase_  :





    """simple docstring"""






    def __init__(							self      ,					SCREAMING_SNAKE_CASE_ = 8     )    ->					None:
         __lowerCamelCase       :     List[str]        =		0b0
         __lowerCamelCase       :     int        =		size







    def 				lowercase_    (							self      ,					SCREAMING_SNAKE_CASE_     )    ->					None:
         __lowerCamelCase       :     List[Any]        =		self.hash_(SCREAMING_SNAKE_CASE_     )
         self.bitarray |= h







    def 				lowercase_    (							self      ,					SCREAMING_SNAKE_CASE_     )    ->					bool:
         __lowerCamelCase       :     Optional[Any]        =		self.hash_(SCREAMING_SNAKE_CASE_     )
         return (h & self.bitarray) == h







    def __contains__(							self      ,					SCREAMING_SNAKE_CASE_     )    ->					bool:
         return self.exists(SCREAMING_SNAKE_CASE_     )







    def 				lowercase_    (							self      ,					SCREAMING_SNAKE_CASE_     )    ->					str:
         __lowerCamelCase       :     Dict        =		bin(SCREAMING_SNAKE_CASE_     )[2:]
         return res.zfill(self.size     )







    @property
    def 				lowercase_    (							self     )    ->					str:
         return self.format_bin(self.bitarray     )







    def 				lowercase_    (							self      ,					SCREAMING_SNAKE_CASE_     )    ->					int:
         __lowerCamelCase       :     Tuple        =		0b0
         for func in HASH_FUNCTIONS:
              __lowerCamelCase       :     Dict        =		(
                  int.from_bytes(func(value.encode()     ).digest()      ,					'little'     ) % self.size
              )
              res |= 2**position
         return res







    def 				lowercase_    (							self      ,					SCREAMING_SNAKE_CASE_     )    ->					str:
         return self.format_bin(self.hash_(SCREAMING_SNAKE_CASE_     )     )







    @property
    def 				lowercase_    (							self     )    ->					float:
         __lowerCamelCase       :     Union[str, Any]        =		bin(self.bitarray     ).count('1'     )
         return (n_ones / self.size) ** len(SCREAMING_SNAKE_CASE_     )










'''simple docstring'''



import math
from itertools import permutations



def       UpperCAmelCase__ (     UpperCAmelCase_   :    int							)					->		bool:

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



def       UpperCAmelCase__ (     UpperCAmelCase_   :    int				,   UpperCAmelCase_   :    list							)					->		bool:
     __lowerCamelCase    ,	__lowerCamelCase       :     str        =		0, len(UpperCAmelCase_							) - 1
     while left <= right:
          __lowerCamelCase       :     Optional[Any]        =		(left + right) // 2
          if prime_list[middle] == target:
               return True
          elif prime_list[middle] < target:
               __lowerCamelCase       :     Union[str, Any]        =		middle + 1
          else:
               __lowerCamelCase       :     Union[str, Any]        =		middle - 1

     return False



def       UpperCAmelCase__ (     )					->		List[str]:
     __lowerCamelCase       :     Tuple        =		[n for n in range(10_01				,   1_00_00				,   2							) if is_prime(UpperCAmelCase_							)]
     __lowerCamelCase       :     Any        =		[]

     for number in prime_list:
          __lowerCamelCase       :     Optional[int]        =		[]

          for prime_member in permutations(list(str(UpperCAmelCase_							)							)							):
               __lowerCamelCase       :     int        =		int(''.join(UpperCAmelCase_							)							)

               if prime % 2 == 0:
                    continue

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

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

     __lowerCamelCase       :     int        =		[]
     for candidate in candidates:
          __lowerCamelCase       :     Union[str, Any]        =		len(UpperCAmelCase_							)
          __lowerCamelCase       :     Optional[Any]        =		False

          for i in range(UpperCAmelCase_							):
               for j in range(i + 1				,   UpperCAmelCase_							):
                    for k in range(j + 1				,   UpperCAmelCase_							):
                         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]]							)							)
                              __lowerCamelCase       :     List[str]        =		True

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

     __lowerCamelCase       :     List[Any]        =		set()
     for seq in passed:
          answer.add(''.join([str(UpperCAmelCase_							) for i in seq]							)							)

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


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






