-- yukicoder My Practice -- author: Leonardone @ NEETSDKASU main = print . solve =<< readLn solve n = ans where t = filter f $ takeWhile g [1..] f x = mod n x == 0 g x = x * x <= n ans = foldl h 0 t h a x | u == w = a + 1 | otherwise = a + 2 where u = show x ++ show y w = show y ++ show x y = div n x