


"""simple docstring"""





import math


def    _snake_case  (  _snake_case :	int	):
      lowerCAmelCase    :		str				=      [True] * n
      lowerCAmelCase    :		List[str]				=      False
      lowerCAmelCase    :		Dict				=      False
      lowerCAmelCase    :		List[Any]				=      True

      for i in range(3       ,      int(n**0.5 + 1	)       ,      2	):
            lowerCAmelCase    :		List[Any]				=      i * 2
            while index < n:
                  lowerCAmelCase    :		Union[str, Any]				=      False
                  lowerCAmelCase    :		List[str]				=      index + i

      lowerCAmelCase    :		int				=      [2]

      for i in range(3       ,      _snake_case       ,      2	):
            if is_prime[i]:
                  primes.append(_snake_case	)

      return primes


def    _snake_case  (  _snake_case :	int = 999966663333	):
      lowerCAmelCase    :		Any				=      math.floor(math.sqrt(_snake_case	)	) + 100
      lowerCAmelCase    :		str				=      prime_sieve(_snake_case	)

      lowerCAmelCase    :		List[str]				=      0
      lowerCAmelCase    :		str				=      0
      lowerCAmelCase    :		int				=      primes[prime_index]

      while (last_prime**2) <= limit:
            lowerCAmelCase    :		Optional[Any]				=      primes[prime_index + 1]

            lowerCAmelCase    :		int				=      last_prime**2
            lowerCAmelCase    :		Any				=      next_prime**2

            # Get numbers divisible by lps(current)
            lowerCAmelCase    :		Optional[Any]				=      lower_bound + last_prime
            while upper_bound > current <= limit:
                  matches_sum += current
                  current += last_prime

            # Reset the upper_bound
            while (upper_bound - next_prime) > limit:
                  upper_bound -= next_prime

            # Add the numbers divisible by ups(current)
            lowerCAmelCase    :		int				=      upper_bound - next_prime
            while current > lower_bound:
                  matches_sum += current
                  current -= next_prime

            # Remove the numbers divisible by both ups and lps
            lowerCAmelCase    :		List[str]				=      0
            while upper_bound > current <= limit:
                  if current <= lower_bound:
                        # Increment the current number
                        current += last_prime * next_prime
                        continue

                  if current > limit:
                        break

                  # Remove twice since it was added by both ups and lps
                  matches_sum -= current * 2

                  # Increment the current number
                  current += last_prime * next_prime

            # Setup for next pair
            lowerCAmelCase    :		List[str]				=      next_prime
            prime_index += 1

      return matches_sum


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






"""simple docstring"""





def    _snake_case  (  _snake_case :	int	):

      if not isinstance(_snake_case       ,      _snake_case	):
            raise TypeError('''only integers accepted as input'''	)
      else:
            lowerCAmelCase    :		List[str]				=      str(abs(_snake_case	)	)
            lowerCAmelCase    :		Optional[Any]				=      [list(_snake_case	) for char in range(len(_snake_case	)	)]
            for index in range(len(_snake_case	)	):
                  num_transpositions[index].pop(_snake_case	)
            return max(
                int(''''''.join(list(_snake_case	)	)	) for transposition in num_transpositions	)


if __name__ == "__main__":
 __import__('''doctest''').testmod()


