def gcd(x, y)
  while true
    r = x % y
    break if r == 0
    x = y
    y = r
  end
  return y
end

a, b = gets.split.map(&:to_i)
g = gcd(a, b)

count = 1
flag = false
while g % 2 == 0 do
  g /= 2
  flag = true
end
count += 1 if flag

sqr = Math.sqrt(g).to_i
3.step(sqr, 2) do |d|
  flag = false
  while g % d == 0 do
    g /= d
    flag = true
  end
  count += 1 if flag
end
count += 1 if g > 1
puts count
