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

k = 1
divisor = []
while k ** 2 <= M
  if M % k == 0
    divisor.push(k)
    divisor.push(M / k)
  end
  k += 1
end

divisor.sort!.reverse!
puts divisor.bsearch{|n| n <= M / N}