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()))
N, M = list(map(int, input().split()))



l = []

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

    if M%i==0:

        l.append(M//i)

        if M//i != i:

            l.append(i)

l.sort(reverse=True)



for i in l:

    a = M//i

    if a >= N:

        print(i)

        break
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()))

N, M = list(map(int, input().split()))
l = []
for i in range(1, int(M**0.5) + 1):
    if M % i == 0:
        l.append(M // i)
        if M // i != i:
            l.append(i)
l.sort(reverse=True)
for i in l:
    a = M // i
    if a >= N:
        print(i)
        break

-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())) +N, M = list(map(int, input().split())) +l = [] +for i in range(1, int(M**0.5) + 1): +    if M % i == 0: +        l.append(M // i) +        if M // i != i: +            l.append(i) +l.sort(reverse=True) +for i in l: +    a = M // i +    if a >= N: +        print(i) +        break