solve :: Int -> Int
solve n = foldl (+) 0 $ filter (\x -> x > 0 && n `div` x == n `mod` x) [ n `div` c - 1 | c <- (takeWhile (\x -> x * x <= n) [1..]), n `mod` c == 0 ]

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