##templete

require "prime"


def gcd(a,b)
  if b>a
     gcd(b,a)
  end

  if a%b == 0
    return b
  end
r = a%b

 return gcd(b,r)
end

a, b = gets.chomp.split(" ").map{|e| e.to_i}

g = gcd(a, b)

pr = Prime.prime_division(g)


ans = pr.length + 1

puts ans
