import sys

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

a=M//N

for i in range(a,0,-1):

    if M%i==0:

        print(i)

        sys.exit()
import sys

import math

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

ans=0

a=min(M+1,10**5)

b=M//N

for i in range(1,a):

    if M%i!=0:

        continue

    if i<=b:

        ans=max(ans,i)

    if M//i <=b:

        ans=max(ans,M//i)

print(ans)

        



import sys

N, M = list(map(int, input().split()))
a = M // N
for i in range(a, 0, -1):
    if M % i == 0:
        print(i)
        sys.exit()

import sys
import math

N, M = list(map(int, input().split()))
ans = 0
a = min(M + 1, 10**5)
b = M // N
for i in range(1, a):
    if M % i != 0:
        continue
    if i <= b:
        ans = max(ans, i)
    if M // i <= b:
        ans = max(ans, M // i)
print(ans)

+import math -a = M // N -for i in range(a, 0, -1): -    if M % i == 0: -        print(i) -        sys.exit() +ans = 0 +a = min(M + 1, 10**5) +b = M // N +for i in range(1, a): +    if M % i != 0: +        continue +    if i <= b: +        ans = max(ans, i) +    if M // i <= b: +        ans = max(ans, M // i) +print(ans)