import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
  n <- getInt

  let solve i res | i*i >     n    = res
                  | n `mod` i == 0 = let m1 = i - 1
                                         q1 = if m1 > 0 then n `div` m1 else -1
                                         r1 = if m1 > 0 then n `mod` m1 else 0

                                         m2 = n `div` i - 1
                                         q2 = n `div` m2
                                         r2 = n `mod` m2

                                         res' = res
                                           + (if q1 == r1 then m1 else 0)
                                           + (if q2 == r2 then m2 else 0)
                                     in solve (i+1) res'
                  | otherwise      = solve (i+1) res

  print $ solve 1 0