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



num = []

i = 1

while i * i <= m:

    if m % i == 0:

        num.append(i)

        if m // i != i:

            num.append(m//i)

    i += 1



ans = 0

for i in num:

    if i <= m // n:

        ans = max(ans, i)



print(ans)
import math

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



div = []

sqrt_m = int(math.sqrt(m))

for i in range(1, sqrt_m + 1):

    if m % i == 0:

        div.append(i)

        div.append(m // i)



div.sort(reverse=True)

for i in div:

    if m >= i * n and (m - i * n) % i == 0:

        print(i)

        exit()
n, m = list(map(int, input().split()))
num = []
i = 1
while i * i <= m:
    if m % i == 0:
        num.append(i)
        if m // i != i:
            num.append(m // i)
    i += 1
ans = 0
for i in num:
    if i <= m // n:
        ans = max(ans, i)
print(ans)

import math

n, m = list(map(int, input().split()))
div = []
sqrt_m = int(math.sqrt(m))
for i in range(1, sqrt_m + 1):
    if m % i == 0:
        div.append(i)
        div.append(m // i)
div.sort(reverse=True)
for i in div:
    if m >= i * n and (m - i * n) % i == 0:
        print(i)
        exit()

+import math + -num = [] -i = 1 -while i * i <= m: +div = [] +sqrt_m = int(math.sqrt(m)) +for i in range(1, sqrt_m + 1): -        num.append(i) -        if m // i != i: -            num.append(m // i) -    i += 1 -ans = 0 -for i in num: -    if i <= m // n: -        ans = max(ans, i) -print(ans) +        div.append(i) +        div.append(m // i) +div.sort(reverse=True) +for i in div: +    if m >= i * n and (m - i * n) % i == 0: +        print(i) +        exit()