N,M = gets.strip.split.map(&:to_i)

require 'prime'

class Integer
  def my_divisor_list2
    return [1] if self == 1
    Prime.prime_division(self).map do |e|
      Array.new(e[1]+1).map.with_index do |element, i|
        e[0]**i
      end
    end.inject{|p,q| p.product(q)}.map do |a|
      [a].flatten.inject(&:*)
    end.sort
  end
end

i = 0
x = M.my_divisor_list2
cnt = M
while x[i] <= M
  if x[i] > (M/N)
    cnt = x[i - 1]
    break
  end
  i += 1
end

puts cnt