a, b = gets.split.map(&:to_i)
a, b = b, a if b < a
nums = Array.new(a) { true }
nums[0] = nums[1] = false
ans = 1

2.upto(a / 2) do |i|
  next unless nums[i]
  if a % i == 0 && b % i == 0
    i.step(nums.size - 1, i) do |j|
      nums[j] = false
    end
    ans += 1
  end
end

puts ans