import Data.List

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

factorization :: Int -> [Int]
factorization 1 = []
factorization n
  | factors == []  = [n]
  | otherwise = factors ++ factorization (n `div` (head factors))
  where factors = take 1 $ filter (\x -> (n `mod` x) == 0) [2 .. n-1]

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