main :: IO ()
main = do
  n <- readLn
  print $ ans n - app n

ans :: Int -> Int
ans n = (\(a,b) -> a-b) $ foldl (\(s,t) (p,a) -> (s*div (p^(a+1)-1) (p-1), t*(a+1))) (1,1) ls where
  (f:fs) = factorize n
  ls = (\(a,b,c) -> (a,b):c) $ foldl (\(a,b,c) l -> if a == l then (a,b+1,c) else (l,1,(a,b):c)) (f,1,[]) fs

app :: Int -> Int
app n = foldl (\acc k -> if n `mod` k == 0 then acc+k-1 else acc) 0 [2..sqrt' n] where
  sqrt' n = (floor . sqrt . fromIntegral) n

factorize :: Int -> [Int]
factorize n
  | n == 1    = []
  | otherwise = let p = find' (\k -> n `mod` k == 0) primes in p : factorize (n `div` p)
  where find' p = head . filter p

primes :: [Int]
primes = filter bePrime [1..]

bePrime :: Int -> Bool
bePrime n
  | n <= 1    = False
  | n == 2    = True
  | otherwise = and [n `mod` m /= 0 | m <- takeWhile (<= sqrt' n) primes]
  where sqrt' n = (floor . sqrt . fromIntegral) n