def factoring(n)
  res = Hash.new(0)
  i = 2
  while i*i <= n
    while n % i == 0
      res[i] += 1
      n /= i
    end
    i += 1
  end
  res[n] = 1 if n != 1
  res
end

A, B = gets.split.map(&:to_i)
a_f = factoring(A).keys
b_f = factoring(B).keys

cd = (a_f + b_f).group_by{ |e| e }.select { |k, v| v.size > 1 }.map(&:first)

puts cd.count + 1