a,b = gets.chomp.split.map(&:to_i)
require 'prime'
primes_a = Prime.prime_division(a)
primes_b = Prime.prime_division(b)

cnt = 0
primes_b = primes_b.map do |prime_b|
    prime_b[0]    
end
for prime_a in primes_a do
    if primes_b.include?(prime_a[0])
        cnt += 1
    end
end
p cnt+1