A,B=gets.split.map(&:to_i)
require "Prime"
class Integer
    def divisor_list
        return [1] if self == 1
        (1..Math.sqrt(self).to_i).select do |i|
            self%i == 0
        end.map {|e| [e, self/e]}.flatten.uniq.sort
    end
end
list=(A.divisor_list & B.divisor_list)
list.delete_if{|e|e!=1 && !Prime.prime?(e)}
p list.size
