import Data.List
import Data.Maybe

main = interact $ show . sol . read

sol :: Int -> Int
sol n = sum . sig n $ takeWhile (\p -> p*p <= n) primes
  where
  f n = floor $ sqrt (2*fromIntegral n+0.25)-0.5
  sig 1  _ = []
  sig _ [] = [1]
  sig n (p:ps) 
    | e > 0     = f e:sig (n `div` p^e) ps
    | otherwise = sig n ps 
    where
    e = pred . fromJust $ find ((>0) . mod n . (p^)) [1..]

primes = sm++lg
  where
  1:p:cs = f $ foldl g (1,[1]) sm
  sm = [2,3,5,7]
  lg = p:filter pr cs
  pr n = all ((>0) . (n `mod`)) $ takeWhile (\p -> p*p <= n) lg
  f (n,rs) = [n*k+r | k <- [0..], r <- rs]
  g (n,rs) p = (p*n,[r2 | k <- [0..(p-1)], r <- rs, let r2 = n*k+r, r2 `mod` p>0])