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

    def prime?
        s=prime**(1/2.0).to_i+1
        for i in 2..s
            if self%i == 0
                return false
            end
        end
        return true
    end
end
list=(A.divisor_list & B.divisor_list)
list.delete_if{|e|e!=1 && !Prime.prime?(e)}
p list.size
