require "prime"

a, b = $stdin.readline.chomp.split(' ').map(&:to_i)

gcd = a.gcd(b)

cds = 1

Prime.each do |p|
  if p <= gcd
    if a.remainder(p).zero? && b.remainder(p).zero?
      cds += 1
    end
  else
    break
  end
end

puts cds
