main :: IO ()
main = do
  [a, b] <- map read . words <$> getLine
  print $ solve a b

solve :: Int -> Int -> Int
solve a b = n + 1 where
  n = length . primeFactorsSet $ gcd a b

primeFactorsSet :: Int -> [Int]
primeFactorsSet n = go n 2 []
  where
    go m i xs
      | i * i >= m = if m == 1 then xs else m:xs
      | q == 0     = go r (i + 1) (i:xs)
      | otherwise  = go m (i + 1) xs
      where
        (p, q) = divMod m i
        r = until (\a -> a `mod` i /= 0) (\a -> a `div` i) p
