module Main where

import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Char
import qualified Data.Map.Strict as M
-- import Debug.Trace

main :: IO ()
main = do
  [a, b] <- unfoldr (BS.readInteger . BS.dropWhile isSpace) <$> BS.getLine
  let 
    a' = M.filter (/= 0) $ M.fromAscList $ primeFactor a 
    b' = M.filter (/= 0) $ M.fromAscList $ primeFactor b 
  print . succ . M.size $ M.intersection a' b'


-- http://qiita.com/myuon_myon/items/ad006568bd187223f494#2-4
primes = 2:3:[x|i<-[1..], j<-[-1,1], let x = 6*i+j, isPrime x] where
  isPrime n = null [i|i<-takeWhile (\x -> x*x <= n) primes, rem n i == 0]

-- | returns [(PrimeFactor, Exponent)]
-- >>> primeFactor 9
-- [(2,0),(3,2)]
primeFactor x = go x primes
  where       
    ub = ceiling . sqrt $ fromIntegral (x + 1)
    go x (p:ps) 
      | p > ub = []
      | otherwise = let (x', e) = gogo x p 0
      in (p, e) : go x' ps
      where
        gogo x p e = case quotRem x p of
          (q, 0) -> gogo q p (e + 1)
          (q, _) -> (x, e)
