def divisors(n)
  r = []
  1.upto(n) do |i|
    break unless i <= n / i
    next unless (n % i).zero?
    r << i
    r << n / i if i != n / i
  end
  r
end
A,B=gets.split.map(&:to_i)
r=[]
(divisors(A) & divisors(B)).sort.each do |d|
  r << d if r.all?{|i| d.gcd(i)==1}
end
p r.size