import Data.List

main = do
    n <- readLn
    print . sum . filter (check n) . map pred $ divisor n

check n m | m == 0 = False
          | otherwise = p == q
          where (p,q) = n `divMod` m

divisor n = foldr f [] $ takeWhile ((<= n) . (^ 2)) [1 .. n]
  where
    f x ds
      | r == 0
      , q /= x = x : q : ds
      | r == 0 = x : ds
      | otherwise = ds
      where
        (q, r) = n `divMod` x