function input()
  local inp = io.read()
  local r={}
  string.gsub(inp,"(%S+)", function (v) table.insert(r,tonumber(v)) end)
  return r
end

local n,m
local inp = input()
n = inp[1]
m = inp[2]
local b={}
local cnt = 1
local i=1
while i*i<=m do
  if m%i==0 then
    b[cnt]=i
    cnt = cnt+1
    b[cnt]=m//i
    cnt = cnt+1
  end
  i=i+1
end
local res = 1
for i=1,cnt-1,1 do
  if b[i]*n<=m then
    res = math.max(res,b[i])
  end
end
print(res)