require 'prime'
a,b = gets.split.map(&:to_i)
i = 1
mx = ([a,b].max)**0.5
diva = []
divb = []
while i <= mx
  if a % i == 0
    diva << i
    diva << a/i
  end
  if b % i == 0
    divb << i
    divb << b/i
  end
  i += 1
end
div = (diva & divb).uniq
ans = 0
div.each do |v|
  ans += 1 if v.prime?
end
p ans+1
