import qualified Data.Set as S

divisors n = dedup ds
  where ds' = (filter ((== 0) . (mod n)) . takeWhile ((<= n) . (^ 2))) [1..n]
        ds = foldl (\acc -> \d -> d:(n `div` d):acc) [] ds'
        dedup as = if a0 == a1 then a0:as' else as
          where a0:a1:as' = as

f n d
    | n `mod` d == 0 = f (n `div` d) d
    | otherwise = n `mod` d == 1

solve n = length ks
  where ks1 = (S.fromList . (filter (f n)) . (filter (/= 1)) . divisors) n
        ks2 = (S.fromList . (filter (/= 1)) . divisors) (n - 1)
        ks = S.union ks1 ks2

main = do
    n <- readLn
    print $ solve n
