-- yukicoder My Practice -- author: Leonardone @ NEETSDKASU import qualified Data.Set as S 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 = length $ foldl h S.empty t h a x = S.insert u $ S.insert w a where u = show x ++ show y w = show y ++ show x y = div n x