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

require 'prime'

class Integer
  def divisor_list
  devisors = [1]
  2.upto(self/2) do |i|
    devisors << i if self%i == 0
  end
  devisors << self
  return devisors
end
end

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

puts cnt