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

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

N = a.my_divisor_list
M = b.my_divisor_list

L = N & M

L2 = L.sort {|a, b| b <=> a }
require 'prime'

n = 1
L2.each do |h|
if Prime.prime?(h) == true
  n += 1
end
end

puts n