import qualified Data.List as L
type Pairs a = [(a, Int)]

main = do
    n <- readLn :: IO Integer
    print $ solve n

solve n = sum . favs $ n where
    divs = n : (tail . divisors $ n)
    favs n = [d-1 | d <- divs, n `mod` (d-1) == n `div` (d-1)]

primes :: Integral a => [a]
primes = 2 : filter ((==1) . length . primeFactors) [3,5..]

primeFactors :: Integral a => a -> [a]
primeFactors n = factor n primes where
    factor m (p:ps)
        | m < 0          = -1 : factor (abs m) (p:ps)
        | p*p > m        = [m]
        | m `mod` p == 0 = p : factor (m `div` p) (p:ps)
        | otherwise      = factor m ps

isPrime :: Integral a => a -> Bool
isPrime 1 = False
isPrime n = case (primeFactors n) of
    (_:_:_)     -> False
    _           -> True

isOddComposit :: Integral a => a -> Bool
isOddComposit n = case (primeFactors n) of
    (2:_:_)     -> False
    (_:_:_)     -> True
    _           -> False

factorize :: Integral a => a -> [a]
factorize 1 = []
factorize n = v : factorize (n `div` v)
    where v = head . primeFactors $ n

primeVectors :: Integral a => a -> Pairs a
primeVectors = count . primeFactors
    where count = map (\xs@(x:_) -> (x, length xs)) . L.group

combExp :: Integral a => a -> [Pairs a]
combExp n = map (zip primes') . combs $ exps
    where
        pvs = primeVectors n
        primes' = fst . unzip $ pvs
        exps   = snd . unzip $ pvs
        combs [] = [[]]
        combs (x:xs) = [a:as| a <- [0..x], as <- combs xs]

divisors :: Integral a => a -> [a]
divisors n = init . L.sort . map pvsToNum . combExp $ n
    where pvsToNum = product . map (uncurry (^))
