import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a, b] <- getIntList
    let m = gcd a b
    print . length $ ps m 1

ps m i | i * i <= m && m `mod` i /= 0 = ps m (i + 1)
       | i * i <= m = i : ps (d m i) (i + 1)
       | m == 1 = []
       | otherwise = [m]

d m k | k == 1 = m
      | m `mod` k /= 0 = m
      | otherwise = d (m `div` k) k