import Data.List

main = do
  li <- getLine
  let [a,b] = map read $ words li
  let ans = compute a b
  print ans

-- 共通する素因数の個数を求める
compute :: Int -> Int -> Int
compute a b = succ $ length $ is (sub a) (sub b)

sub n = map head $ group $ primeFactors n

-- ordered intersection
is xxs@(x:xs) yys@(y:ys) =
  case compare x y of
    LT -> is xs yys
    EQ -> x : is xs ys
    GT -> is xxs ys
is _ _ = []

-- 自作の簡易素数と素因数分解
primes = 2 : 3 : 5 : sieve [(9,3),(10,5)] [7,9..]

{- (np,p)のリストと、奇数の列 -}
sieve ((q,p):qps) xxs@(x:xs) =
  case compare q x of
    LT -> sieve qps1 xxs
    EQ -> sieve qps1 xs
    GT -> x : sieve (insert (x+x,x) qps) xs
  where
    qps1 = insert (q+p,p) qps

primeFactors n = loop n primes
  where
    loop 1 _ = []
    loop n pps@(p:ps)
      | r == 0 = p : loop q pps
      | q < p  = [n]
      | True   = loop n ps
      where (q,r) = divMod n p