def gcd(l, s)
  return l if s == 0

  gcd(s, l % s)
end

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

num = gcd(b, a)
prime_factors = []
(2..(num**0.5).to_i).each do |i|
  next if num % i != 0

  prime_factors << i if prime_factors.none? { |s| i % s == 0 }
  prime_factors << (num / i) if prime_factors.none? { |s| (num / i) % s == 0 }
end
prime_factors << num if num != 1 && prime_factors.none? { |s| num % s == 0 }

puts prime_factors.size + 1