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

def dasu(num)
  result = []
  i = 2
  while i <= num do
    if num % i == 0
      result << i
      num = num / i
    else
      i += 1
    end
  end
  return result
end

first = dasu(a)
second = dasu(b)

yaku = first & second
yaku << 1
print yaku.count
