import Data.List

factor :: Int -> [Int]
factor 1 = []
factor n = (prime:) . factor $ n `div` prime
  where divisors = dropWhile ((/=0) . mod n) [2..ceiling . sqrt $ fromIntegral n]
        prime = if null divisors
                then n
                else head divisors

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