import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List
import Data.Char


main :: IO ()
main = do
    n <- readLn
    let xx = (length $ divisors (n-1))
    let ys = divisors n
    let yy = length $ filter ((==) 1) $ zipWith (\x y -> y `mod` x) ys $ map (f n) ys
    print $ xx + yy


f :: Int -> Int -> Int
f n k = if n `mod` k == 0 then f (n`div`k) k else n


divisors :: Int -> [Int]
divisors n = (n:(go [] 2))
    where go :: [Int] -> Int -> [Int]
          go xs count 
              | count > (floor $ sqrt (fromIntegral n)) = xs
              | n `mod` count == 0                      = if n /= count^2 then go ((n`div`count):count:xs) (count+1) else count:xs
              | otherwise                               = go xs (count+1)