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
      return primes.uniq
    rescue ZeroDivisionError
      return
    end
  end

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

gcd_val = A.gcd(B)
puts gcd_val.my_divisor_list.length + 1
