'''simple docstring'''


import math
from itertools import permutations


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


def    _lowerCamelCase       ( lowerCamelCase_   :				int      ,	lowerCamelCase_   :				list  ):



     """simple docstring"""





     UpperCAmelCase_  ,     UpperCAmelCase_				:  Optional[Any]  = 0, len(lowerCamelCase_  ) - 1
     while left <= right:
          UpperCAmelCase_				:  Dict  = (left + right) // 2
          if prime_list[middle] == target:
               return True
          elif prime_list[middle] < target:
               UpperCAmelCase_				:  int  = middle + 1
          else:
               UpperCAmelCase_				:  int  = middle - 1

     return False


def    _lowerCamelCase       ( ):



     """simple docstring"""





     UpperCAmelCase_				:  Dict  = [n for n in range(1001      ,	10000      ,	2  ) if is_prime(lowerCamelCase_  )]
     UpperCAmelCase_				:  Tuple  = []

     for number in prime_list:
          UpperCAmelCase_				:  Tuple  = []

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

               if prime % 2 == 0:
                    continue

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

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

     UpperCAmelCase_				:  Optional[Any]  = []
     for candidate in candidates:
          UpperCAmelCase_				:  Any  = len(lowerCamelCase_  )
          UpperCAmelCase_				:  Tuple  = False

          for i in range(lowerCamelCase_  ):
               for j in range(i + 1      ,	lowerCamelCase_  ):
                    for k in range(j + 1      ,	lowerCamelCase_  ):
                         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_				:  Tuple  = True

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

     UpperCAmelCase_				:  Dict  = set()
     for seq in passed:
          answer.add(''.join([str(lowerCamelCase_  ) for i in seq]  )  )

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


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










class 	a__						:

       def __init__( self   :  int   ,				lowerCamelCase_   :  int     ):
            a_     :  Dict				      =     data
            a_     :  int
            a_     :  Node



def 			_a      (    __UpperCamelCase			):
     a_     :  int				      =     0
     a_     :  Optional[Any]				      =     x



def 			_a      (    __UpperCamelCase	,	__UpperCamelCase			):
     a_      ,      a_     :  Dict				      =     find_set(__UpperCamelCase			), find_set(__UpperCamelCase			)
     if x == y:
          return

     elif x.rank > y.rank:
          a_     :  Tuple				      =     x
     else:
          a_     :  Optional[Any]				      =     y
          if x.rank == y.rank:
               y.rank += 1



def 			_a      (    __UpperCamelCase			):
     if x != x.parent:
          a_     :  Tuple				      =     find_set(x.parent			)
     return x.parent



def 			_a      (    __UpperCamelCase			):
     a_     :  List[Any]				      =     ({0, 1, 2}, {3, 4, 5})
     for s in sets:
          if node.data in s:
               return s
     a_     :  Union[str, Any]				      =     F'''{node.data} is not in {sets}'''
     raise ValueError(__UpperCamelCase			)



def 			_a      (    ):
     a_     :  int				      =     [Node(__UpperCamelCase			) for i in range(6			)]
     for v in vertex:
          make_set(__UpperCamelCase			)

     union_set(vertex[0]	,	vertex[1]			)
     union_set(vertex[1]	,	vertex[2]			)
     union_set(vertex[3]	,	vertex[4]			)
     union_set(vertex[3]	,	vertex[5]			)

     for nodea in vertex:
          for nodea in vertex:
               if find_python_set(__UpperCamelCase			).isdisjoint(find_python_set(__UpperCamelCase			)			):
                    assert find_set(__UpperCamelCase			) != find_set(__UpperCamelCase			)
               else:
                    assert find_set(__UpperCamelCase			) == find_set(__UpperCamelCase			)


if __name__ == "__main__":
       test_disjoint_set()



