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

set = Set.new
(2..Math.sqrt(a)).each do |i|
  p_a = a / i
  if p_a * i == a then
    set << i
    set << p_a
  end
end

set2 = Prime.each(a > b ? a : b).to_set
count = 1
(2..Math.sqrt(b)).each do |i|
  p_b = b / i
  count += 1 if p_b * i == b && set.include?(i) && set2.include?(i)
end

puts count
