import Data.List

primeFactors :: Integer -> [Integer]
primeFactors n = factors n (head primes) (tail primes)
    where factors n p ps
              | n < 2 = []
              | n < p^2 = [n]
              | mod n p == 0 = [p] ++ factors (div n p) p ps
              | otherwise = let (q:qs) = ps in factors n q qs
primes = 2 : filter (\n-> head (primeFactors n) == n) [3, 5..]

main = do
  a:b:_ <- map read . words <$> getLine :: IO [Integer]
  putStrLn $ show $ (1 +) $ length $ nub $ primeFactors $ gcd a b
