import bisect

n, m = list(map(int, input().split()))



fct = []

fct2 = []

sq = int(m**(1/2))

if sq + 1 ==m:

    sq += 1



for f in range(1, sq + 1):

    if m%f == 0:

        fct.append(f)

        fct2.append(m//f)

if fct2[-1] == fct[-1]:

    fct2.pop()



fct2.reverse()



fct += fct2



k = m//n

ind = bisect.bisect_left(fct,k)



print((fct[ind-1] if k<fct[ind] else fct[ind]))
import bisect

n,m = list(map(int, input().split( )))



t = m//n



fct_sup = int(m**(1/2)) + 1



fct = []

fct2 = []

for f in range(1,fct_sup+1):

    if m%f == 0:

        fct.append(f)

        fct2.append(m//f)

if fct[-1] == fct2[-1]:

    fct.pop()

fct2.reverse()

fct += fct2

i = bisect.bisect_right(fct,t)

print((fct[i-1]))



import bisect

n, m = list(map(int, input().split()))
fct = []
fct2 = []
sq = int(m ** (1 / 2))
if sq + 1 == m:
    sq += 1
for f in range(1, sq + 1):
    if m % f == 0:
        fct.append(f)
        fct2.append(m // f)
if fct2[-1] == fct[-1]:
    fct2.pop()
fct2.reverse()
fct += fct2
k = m // n
ind = bisect.bisect_left(fct, k)
print((fct[ind - 1] if k < fct[ind] else fct[ind]))

import bisect

n, m = list(map(int, input().split()))
t = m // n
fct_sup = int(m ** (1 / 2)) + 1
fct = []
fct2 = []
for f in range(1, fct_sup + 1):
    if m % f == 0:
        fct.append(f)
        fct2.append(m // f)
if fct[-1] == fct2[-1]:
    fct.pop()
fct2.reverse()
fct += fct2
i = bisect.bisect_right(fct, t)
print((fct[i - 1]))

+t = m // n +fct_sup = int(m ** (1 / 2)) + 1 -sq = int(m ** (1 / 2)) -if sq + 1 == m: -    sq += 1 -for f in range(1, sq + 1): +for f in range(1, fct_sup + 1): -if fct2[-1] == fct[-1]: -    fct2.pop() +if fct[-1] == fct2[-1]: +    fct.pop() -k = m // n -ind = bisect.bisect_left(fct, k) -print((fct[ind - 1] if k < fct[ind] else fct[ind])) +i = bisect.bisect_right(fct, t) +print((fct[i - 1]))