def f():

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

  for i in range(m//n+1)[::-1]:

    if m%i==0:return i

print((f()))
import math



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





ans = 0

for i in range(1, math.ceil(math.sqrt(m))+1):

    if m % i == 0:

        if min(i, m//i) >= n:

            ans = max(ans, max(i, m//i))

        elif max(i, m//i) >= n:

            ans = max(ans, min(i, m//i))

print(ans)
def f():
    n, m = list(map(int, input().split()))
    for i in range(m // n + 1)[::-1]:
        if m % i == 0:
            return i


print((f()))

import math

n, m = list(map(int, input().split()))
ans = 0
for i in range(1, math.ceil(math.sqrt(m)) + 1):
    if m % i == 0:
        if min(i, m // i) >= n:
            ans = max(ans, max(i, m // i))
        elif max(i, m // i) >= n:
            ans = max(ans, min(i, m // i))
print(ans)

-def f(): -    n, m = list(map(int, input().split())) -    for i in range(m // n + 1)[::-1]: -        if m % i == 0: -            return i +import math - -print((f())) +n, m = list(map(int, input().split())) +ans = 0 +for i in range(1, math.ceil(math.sqrt(m)) + 1): +    if m % i == 0: +        if min(i, m // i) >= n: +            ans = max(ans, max(i, m // i)) +        elif max(i, m // i) >= n: +            ans = max(ans, min(i, m // i)) +print(ans)