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

if a > b
  tmp = b
  b = a
  a = tmp
end

res = []

1.upto(Math.sqrt(b).to_i) do |i|
  next unless i.prime? || i == 1
  res << i if a % i == 0 && b % i == 0
end

puts res.size