primes_til n = sieve (2: [3, 5 .. n])
primes = sieve (2: [3, 5..])
sieve [] = []
sieve (p:xs) = p : sieve [x | x <- xs, x `mod` p /= 0]

factors n =
  [p | p <- primes_til n, p <= n, n `mod` p == 0]
  
merge [] _ = []
merge _ [] = []
merge (x:xs) (y:ys) =
  if x == 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_l  = 1 : merge facta factb 
  let ans = length ans_l
  putStrLn $ show ans
  