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

ans = 0
(1..(M**(0.5))).each do |n|
  next if M % n != 0

  if (N * n) <= M
    ans = [ans, n].max
  end

  m = M / n
  if (N * m) <= M
    ans = [ans, m].max
  end
end

puts ans
