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

require 'prime'

class Integer
  def my_divisor_list3
    return [1] if self == 1
    first, *rest = Prime.prime_division(self).map do |p, k|
      (0..k).map{|i| p**i}
    end
    first.product(*rest).map do |a|
      a.inject(&:*)
    end.sort
  end
end

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