{-# LANGUAGE BangPatterns #-}
import qualified Data.IntMap as IM

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

solve :: Int -> Int
solve n = sum [ m | m <- pred <$> divisors n, m > 0, let (q, r) = n `divMod` m, q == r ]

divisors :: Int -> [Int]
divisors = go [1] . factorize
  where
    go !xs !mp = case IM.minViewWithKey mp of
      Nothing            -> xs
      Just ((k, v), mp') -> go xs' mp'
        where
          xs' = (*) <$> xs <*> [ k ^ i | i <- [0..v] ]

factorize :: Int -> IM.IntMap Int
factorize = go primes IM.empty
  where
    go ps@(p:ps') !mp !n
      | p > n     = mp
      | r == 0    = go ps  mp' q
      | otherwise = go ps' mp  n
      where
        (q, r) = n `divMod` p
        mp'    = IM.insertWith (+) p 1 mp

primes :: [Int]
primes = 2 : go [3] [3, 5..]
  where
    go (x:xs) ys = ps ++ go (xs ++ ps) [ z | z <- qs, z `mod` x > 0 ]
      where
        (ps, qs) = span (< x ^ 2) ys