main :: IO ()

isPrime :: Int -> Bool
isPrime 1 = False
isPrime 2 = True
isPrime n | (length [x | x <- [2 .. n-1], mod n x == 0]) > 0 = False
          | otherwise = True

main = do
    [a,b] <- map read . words <$> getLine :: IO [Int]
    let g = gcd a b
        gs = [i | i <- [1..g], a `mod` i == 0 && b `mod` i == 0]
    print . length $ filter (\i -> isPrime i || i == 1) gs
