class Integer
  def divisors
    res = []
    1.upto((self**0.5)) do |i|
      if self % i == 0
        res.push i
        res.push self / i if i != self / i
      end
    end
    res.sort!
    block_given? ? res.each{|t| yield t } : res
  end
end

n, m = gets.to_s.split.map{|t| t.to_i }

m.divisors.reverse_each do |t|
  if m / t >= n
    puts t
    exit
  end
end