local function gcd(a,b)
    if b>0 then
        return gcd(b,a%b)
    else
        return a
    end
end

local a,b=io.read("n","n")
local gcdab=gcd(a,b)

local counter=1
for i=2,math.sqrt(gcdab) do
    if gcdab%i==0 then
        while gcdab%i==0 do
            gcdab=gcdab//i
        end
        counter=counter+1
    end
end
print(gcdab>1 and counter+1 or counter)