factors n =
  let loop_j n i j =
        if n `mod` i == 0 then
          loop_j (n `div` i) i (j + 1)
        else
          (n, j)
  in
    let loop_i n i =
          if i * i > n then
            if n == 1 then [] else [(n, 1)]
          else if n `mod` i == 0 then
            let (n', c) = loop_j (n `div` i) i 1
            in
              (i, c) : loop_i n' (i + 1)
          else
            loop_i n (i + 1)
    in
      loop_i n 2
  
merge [] _ = []
merge _ [] = []
merge (x:xs) (y:ys) =
  if fst x == fst y then
    x : merge xs ys
  else if x < y then
         merge xs (y:ys)
       else
         merge (x:xs) ys

main = do
  [a,b] <- map read . words <$> getLine
  let facta = factors a
  let factb = factors b 
  let ans = 1 + length (merge facta factb )
  putStrLn $ show ans
  
