import Data.List

factor 1 = []
factor n = let divisors = dropWhile ((/= 0) . mod n) [2 .. ceiling $ sqrt $ fromIntegral n]
           in let prime = if null divisors then n else head divisors
              in (prime :) $ factor $ div n prime

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