import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (unfoldr)

main :: IO ()
main = do
  let
    primeFactors :: Int -> [(Int, Int)]
    primeFactors n = filter ((/= 0) . snd) . unfoldr next $ Just (n, 2, 0)
      where
        next (Just (m, d, c)) | m < d     = Just ((d, c), Nothing)
                              | r == 0    = next (Just (m', d, succ c))
                              | m < d ^ 2 = Just ((d, c), Just (m, m, 0))
                              | otherwise = Just ((d, c), Just (m, succ d, 0))
          where
            (m', r) = m `divMod` d
        next _                            = Nothing
    f :: Int -> Int
    f m = head . dropWhile ((2 * m <) . ((*) <$> id <*> succ)) $ [8, 7..0] :: Int
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  print . sum . map (f . snd) . primeFactors $ n

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}
