import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (a : b : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  print . f $ gcd a b

f :: Int -> Int
-- f = \n -> fst . foldl step (1, n) $ [2..(n `div` 2)]
f = \n -> length . filter ((== 0) . mod n) . takeWhile (<= n) $ primes

primes :: [Int]
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, n `mod` i == 0]

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n
