require 'prime'

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

a_f = a.prime_division
b_f = b.prime_division

arr = []
delete_f = true
a_f.each do |aa|
  while delete_f do
    b_f.delete_if do |bb|
      if aa[0] == bb[0]
        arr << aa[0]
        delete_f = false
        true
      elsif aa[0] < bb[0]
        false
      else
        true
      end
    end
    delete_f = false
  end
  delete_f = true
end

puts arr.size + 1