require 'prime'

a, b = gets.split.map(&:to_i)

gcd = a.gcd(b)
cds = []
cds << 1
cds << gcd if gcd != 1

unless gcd.prime?
  2.upto(gcd) do |i|
    break if cds.last == i

    (cds << i << gcd / i) if gcd % i == 0
  end
end
answer = cds

cds.sort!.each do |cd|
  next if cd == 1
  answer.reject! { |num| num % cd == 0 && num != cd }
end

puts answer.size
