input = gets.chomp.split(" ").map(&:to_i).sort
i = 2
result = []
count = 1

while (i <= input[0]) do
  answer = true
  result.each do |e|
    if i%e ==0
      answer = false
      break
    end
  end
  if answer && (input[0]%i ==0)
    result << i
    input[0] = input[0]/i
  end
  i += 1
end

result.each do |e|
  if input[1]%e ==0
    count += 1
  end
end


puts count