local n, m = io.read("*n", "*n")
local i = 1
local ret = 1
local mma = math.max
while true do
  if m % i == 0 then
    local j = m // i
    if n <= j then ret = mma(ret, i) end
    if n <= i then ret = mma(ret, j) end
  end
  if m < i * i then break end
  i = i + 1
end
print(ret)
