import Data.List

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

factorization :: Int -> [Int]
factorization 1 = []
factorization x = v : factorization (x `div` v)
  where
    v = factors x !! 1

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