import Data.List

factors :: Int -> [Int]
factors n = [x | x <- [1..n], n `mod` x == 0]

primeFactors :: Int -> [Int]
primeFactors a = let (f, f1) = factorPairOf a
                     f' = if prime f then [f] else primeFactors f
                     f1' = if prime f1 then [f1] else primeFactors f1
                 in f' ++ f1'
 where
 factorPairOf a = let f = head $ factors a
                  in (f, a `div` f)
 factors a    = filter (isFactor a) [2..a-1]
 isFactor a b = a `mod` b == 0
 prime a      = null $ factors a

main :: IO ()
main = do
  [a, b] <- map read . words <$> getLine
  print . (+1) . length . group . primeFactors $ gcd a b