import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T
import Data.List (unfoldr)

main :: IO ()
main = do
  let
    primeFactors :: Int -> [(Int, Int)]
    primeFactors n = filter ((/= 0) . snd) . unfoldr next $ Just (n, 2, 0)
      where
        next :: Maybe (Int, Int, Int) -> Maybe ((Int, Int), Maybe (Int, Int, Int))
        next (Just (m, d, c)) | m < d     = Just ((d, c), Nothing)
                              | r == 0    = next (Just (m', d, succ c))
                              | m < d * d = Just ((d, c), Just (m, m, 0))
                              | otherwise = Just ((d, c), Just (m, succ d, 0))
          where
            (m', r) = m `divMod` d
        next _                            = Nothing
  [a, b] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    x = gcd a b :: Int
  print . (1 +) . length . primeFactors $ x

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}
