require 'prime'

num = gets.split(' ').map(&:to_i)

gcd = num[0].gcd(num[1])
divisor = [1]

Prime.each(gcd) do |num|
    if gcd % num == 0 
        divisor.each_with_index do |div, index|
            if div.gcd(num) == 1 
                if index == divisor.size - 1
                    divisor.push(num)
                end
            else
                break
            end
        end
    end
end

puts divisor.size