module Main where

import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Char
import Control.Arrow
import qualified Data.IntSet as IntSet
import qualified Data.Vector.Unboxed as VU

main :: IO ()
main = do
  [n] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  print $ ans n 
  where
    f = VU.fromList . IntSet.toList . IntSet.fromList . map product . subsequences . primeFactor'
    ans n = let
      factors = f n
      l = VU.length factors
      in if odd l 
        then let x = factors VU.! div l 2 in (x - 1) * 2
        else let 
          x = factors VU.! div l 2
          y = factors VU.! (div l 2 - 1)
        in (x - 1) + (y - 1)

-- http://qiita.com/myuon_myon/items/ad006568bd187223f494#2-4
primes = 2:3:[x|i<-[1..], j<-[-1,1], let x = 6*i+j, isPrime x] where
  isPrime n = null [i|i<-takeWhile (\x -> x*x <= n) primes, rem n i == 0]

-- >>> primeFactor' 9
-- [3, 3]
primeFactor' x = go x divisor
  where
    go 1 [] = []
    go y [] = [y]
    go y ps'@(p : ps) = case quotRem y p of
      (q, 0) -> p : go q ps'
      (q, _) -> go y ps
    ub = floor . sqrt $ fromIntegral x
    divisor = takeWhile (<= ub) primes