import Data.Ratio

main = do
    n <- readLn
    print $ eulerPhi n

eulerPhi :: Integer -> Integer
eulerPhi n = floor.fromRational $ (fromInteger n) * (product.map (\x -> 1-1%x) $ factors)
    where factors = map fst.grouping (-1,0).primeFactorize $ n

grouping acc [] = [acc]
grouping acc (x:xs)
  | fst acc == -1 = grouping (x,1) xs
  | fst acc /= x  = acc : grouping (x,1) xs
  | fst acc == x  = grouping (fmap (+1) acc) xs

primeFactorize :: Integer -> [Integer]
primeFactorize n = pf n primes

pf :: Integer -> [Integer] -> [Integer]
pf n (x:xs)
  | x > n = []
  | isPrime n = [n]
  | modnx == 0 = x : pf divnx (x:xs)
  | otherwise = pf n xs
  where (divnx, modnx) = divMod n x

primes :: [Integer]
primes = 2 : filter isPrime [3,5..]

isPrime :: Integer -> Bool
isPrime n = all (/= 0).map (mod n).takeWhile (<= sqrtn) $ primes
    where sqrtn = floor.sqrt.fromIntegral $ n