main = do
  n <- readLn
  print $ length $ totient n

phi :: Int -> [Int]
phi n = 1 : [ x | x <- [2..sqr], gcd n x == 1] ++ [ y | x <- [2..sqr], let y = n `div` x, gcd n x == 1]
  where sqr = floor $ sqrt $ fromIntegral n
--phi n = [x | x <- [2..n], gcd n x == 1 || gcd n x == x]

totient :: Int -> [Int]
totient 1 = [1]
totient a = filter (coprime a) [1..a-1]
 where coprime a b = gcd a b == 1