require 'prime'
class Integer
    def my_divisor_list
      divisors = [1]
      primes = []
      Prime.prime_division(self).each do |prime|
        prime[1].times {primes << prime[0]}
      end
  
      1.upto(primes.size) do |i|
        primes.combination(i) do |prime|
          divisors << prime.inject{|a,b| a *= b}
        end
      end
  
      divisors.uniq!
      divisors.sort!
      return divisors
    rescue ZeroDivisionError
      return
    end
  end

A,B=gets.chomp.split(" ").map(&:to_i)

gcd_val = A.gcd(B)
divs = gcd_val.my_divisor_list

ret = 0
rets = []
while !divs.empty? do
    target = divs.shift
    ret += 1
    rets.push(target)
    next if target == 1
    divs = divs.select { |e| e.gcd(target)==1 }
end
puts ret
