





import math
from itertools import permutations

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

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

   return False

def      __snake_case						(					) ->						List[Any]:
   A_					:				str          =			[n for n in range(1001				,				10000				,				2	) if is_prime(__lowerCamelCase	)]
   A_					:				Dict          =			[]

   for number in prime_list:
      A_					:				str          =			[]

      for prime_member in permutations(list(str(__lowerCamelCase	)	)	):
         A_					:				Optional[int]          =			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	)

   A_					:				Tuple          =			[]
   for candidate in candidates:
      A_					:				Optional[int]          =			len(__lowerCamelCase	)
      A_					:				List[Any]          =			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]]	)	)
                  A_					:				str          =			True

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

   A_					:				int          =			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())







import torch
from torch import autograd


class 					__magic_name__  (							autograd.Function							):





     """simple docstring"""



     @staticmethod
     def 						SCREAMING_SNAKE_CASE		(							snake_case       :Any			,      snake_case       :torch.tensor			,      snake_case       :float			,      snake_case       :bool  ):





        '''simple docstring'''




        A_					:				int          =			inputs.numel()
        A_					:				str          =			int(0.005 * nb_elems  ) + 1
        if sigmoid:
           A_					:				List[Any]          =			(torch.sigmoid(snake_case  ) > threshold).type(inputs.type()  )
        else:
           A_					:				Optional[Any]          =			(inputs > threshold).type(inputs.type()  )
        if mask.sum() < nb_min:
           # We limit the pruning so that at least 0.5% (half a percent) of the weights are remaining
           A_					:				Tuple          =			inputs.flatten().kthvalue(max(nb_elems - nb_min			,      1  )  ).values
           A_					:				Optional[int]          =			(inputs > k_threshold).type(inputs.type()  )
        return mask





     @staticmethod
     def 						SCREAMING_SNAKE_CASE		(							snake_case       :Optional[int]			,      snake_case       :int  ):





        '''simple docstring'''




        return gradOutput, None, None




class 					__magic_name__  (							autograd.Function							):





     """simple docstring"""



     @staticmethod
     def 						SCREAMING_SNAKE_CASE		(							snake_case       :Tuple			,      snake_case       :torch.tensor			,      snake_case       :float  ):





        '''simple docstring'''




        A_					:				Tuple          =			inputs.clone()
        A_      ,						A_					:				Optional[int]          =			inputs.flatten().sort(descending=snake_case  )
        A_					:				Dict          =			int(threshold * inputs.numel()  )

        # flat_out and mask access the same memory.
        A_					:				str          =			mask.flatten()
        A_					:				List[Any]          =			0
        A_					:				List[str]          =			1
        return mask





     @staticmethod
     def 						SCREAMING_SNAKE_CASE		(							snake_case       :List[Any]			,      snake_case       :Optional[Any]  ):





        '''simple docstring'''




        return gradOutput, None




class 					__magic_name__  (							lowerCamelCase__							):





     """simple docstring"""



     @staticmethod
     def 						SCREAMING_SNAKE_CASE		(							snake_case       :torch.tensor			,      snake_case       :float  ):





        '''simple docstring'''




        A_					:				str          =			inputs.clone()
        A_      ,						A_					:				Optional[int]          =			inputs.abs().flatten().sort(descending=snake_case  )
        A_					:				int          =			int(threshold * inputs.numel()  )

        # flat_out and mask access the same memory.
        A_					:				List[str]          =			mask.flatten()
        A_					:				List[str]          =			0
        A_					:				Union[str, Any]          =			1
        return mask
