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



ans = 1

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

    if M % g == 0 and M / g >= N:

        ans = max(ans, g)

    

    if M % g == 0:

        g2 = M // g

        if M % g2 == 0 and M / g2 >= N:

            ans = max(ans, g2)

print(ans)

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



ans = 0

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

    if M % x != 0:

        continue

    else:

        x1, x2 = x, M // x

        if M // x1 >= N:

            ans = max(ans, x1)

        if M // x2 >= N:

            ans = max(ans, x2)



print(ans)

N, M = list(map(int, input().split()))
ans = 1
for g in range(1, int(M**0.5) + 1):
    if M % g == 0 and M / g >= N:
        ans = max(ans, g)
    if M % g == 0:
        g2 = M // g
        if M % g2 == 0 and M / g2 >= N:
            ans = max(ans, g2)
print(ans)

N, M = list(map(int, input().split()))
ans = 0
for x in range(1, int(M**0.5) + 1):
    if M % x != 0:
        continue
    else:
        x1, x2 = x, M // x
        if M // x1 >= N:
            ans = max(ans, x1)
        if M // x2 >= N:
            ans = max(ans, x2)
print(ans)

-ans = 1 -for g in range(1, int(M**0.5) + 1): -    if M % g == 0 and M / g >= N: -        ans = max(ans, g) -    if M % g == 0: -        g2 = M // g -        if M % g2 == 0 and M / g2 >= N: -            ans = max(ans, g2) +ans = 0 +for x in range(1, int(M**0.5) + 1): +    if M % x != 0: +        continue +    else: +        x1, x2 = x, M // x +        if M // x1 >= N: +            ans = max(ans, x1) +        if M // x2 >= N: +            ans = max(ans, x2)