main = do
    n <- readLn
    print $ sum $ solve n

solve :: Int -> [Int]
solve n = filter (>1) [m-1 | m<-factors n, n`div`(m-1)==n`mod`(m-1)]

hfactors :: Int -> [Int]
hfactors n = [x | x<-[2..(ceiling.sqrt.fromIntegral) n], n`mod`x==0]

factors :: Int -> [Int]
factors n = nub $ n:fs ++ map (div n) fs
    where fs = hfactors n