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



n = M

# 約数列挙(1,N)も含まれる

prime, i = set(), 1

while i * i <= n:

    if n % i == 0:

        prime.add(i)

        prime.add(n//i)

    i += 1



ans = 1

l = list(prime)

for i in l:

    if i * N <= M:

        ans = max(ans, i)



print(ans)

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



prime, i = set(), 1

while i * i <= M:

    if M % i == 0:

        prime.add(i)

        prime.add(M//i)

    i += 1



ans = 0

for i in prime:

    if i * N <= M:

        ans = max(ans, i)

print(ans)

N, M = list(map(int, input().split()))
n = M
# 約数列挙(1,N)も含まれる
prime, i = set(), 1
while i * i <= n:
    if n % i == 0:
        prime.add(i)
        prime.add(n // i)
    i += 1
ans = 1
l = list(prime)
for i in l:
    if i * N <= M:
        ans = max(ans, i)
print(ans)

N, M = list(map(int, input().split()))
prime, i = set(), 1
while i * i <= M:
    if M % i == 0:
        prime.add(i)
        prime.add(M // i)
    i += 1
ans = 0
for i in prime:
    if i * N <= M:
        ans = max(ans, i)
print(ans)

-n = M -# 約数列挙(1,N)も含まれる -while i * i <= n: -    if n % i == 0: +while i * i <= M: +    if M % i == 0: -        prime.add(n // i) +        prime.add(M // i) -ans = 1 -l = list(prime) -for i in l: +ans = 0 +for i in prime: