require 'prime'
def isPrime(n)
    f = n.prime_division
    f.length == 1 && f[0][1] == 1
end
def divisor(n)
    if n == 1 then
        return [1]
    end
    x = [1,n]
    [*2..Math.sqrt(n).to_i].each do |a|
        if n%a==0 then
            x.push a if isPrime(a)
            b = n/a
            x.push b if isPrime(b)
        end
    end
    x
end
def commonDivisor(x,y)
    divisor(x)&divisor(y)
end

a,b = gets.split.map(&:to_i)
cd = commonDivisor(a,b)
puts cd.length