def divisor(n):

    ass = []

    for i in range(1, int(n**0.5)+1):

        if n % i == 0:

            ass.append(i)

            ass.append(n//i)

    return ass





N, M = list(map(int, input().split()))



K = divisor(M)



ans = 0

for k in K:

    if N * k <= M:

        ans = max(ans, k)





print(ans)



N, M = list(map(int, input().split()))



# Mの約数列挙

divs = set()

for i in range(1, int(M ** 0.5) + 1):

    if M % i == 0:

        divs.add(i)

        divs.add(M // i)



ans = 0

for d in divs:

    if N * d <= M:

        ans = max(ans, d)



print(ans)

def divisor(n):
    ass = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            ass.append(i)
            ass.append(n // i)
    return ass


N, M = list(map(int, input().split()))
K = divisor(M)
ans = 0
for k in K:
    if N * k <= M:
        ans = max(ans, k)
print(ans)

N, M = list(map(int, input().split()))
# Mの約数列挙
divs = set()
for i in range(1, int(M**0.5) + 1):
    if M % i == 0:
        divs.add(i)
        divs.add(M // i)
ans = 0
for d in divs:
    if N * d <= M:
        ans = max(ans, d)
print(ans)

-def divisor(n): -    ass = [] -    for i in range(1, int(n**0.5) + 1): -        if n % i == 0: -            ass.append(i) -            ass.append(n // i) -    return ass - - -K = divisor(M) +# Mの約数列挙 +divs = set() +for i in range(1, int(M**0.5) + 1): +    if M % i == 0: +        divs.add(i) +        divs.add(M // i) -for k in K: -    if N * k <= M: -        ans = max(ans, k) +for d in divs: +    if N * d <= M: +        ans = max(ans, d)