require 'prime'

def gcd(a,b)
  if a < b
    z = a
    a = b
    b = z
  end
  r = a % b
  while r != 0
    a = b
    b = r
    r = a % b
  end
  b
end

a,b = gets.chomp.split(" ").map(&:to_i)
if a > b
  z = a
  a = b
  b = z
end

ans = 1

Prime.each(Math.sqrt(a).to_i+1).each do |e|
  c = gcd(e,a)
  d = gcd(e,b)
  if c == e
    if d == e
      ans += 1
    end
  end
end

p ans
