N, M = gets.split.map(&:to_i)
if N == 1
  puts M
  exit
end

ans = (1 .. [M / N, Math.sqrt(M).to_i].min).inject(1) do |m,v|
  r,mod = M.divmod(v)
  if mod.zero? && r >= N
    v
  else
    m
  end
end
puts ans
