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

if N==1:

    print(M)

    exit()



if N>=M**0.5:

    for i in range(M//N,0,-1):

        if M%i==0:

            print(i)

            exit()

else:

    for i in range(N,M+1):

        if M%i==0:

            print((M//i))

            exit()

print((1))
def div(N):

    ans = []





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

        if N % i == 0:

            ans.append(i)

            if N // i != i:

                ans.append(N // i)

    ans.sort()

    return ans



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

if N==1:

    print(M)

    exit()



divM=div(M)



for i in range(1,len(divM)):

    if divM[i]>M//N:

        print((divM[i-1]))

        exit()

N, M = list(map(int, input().split()))
if N == 1:
    print(M)
    exit()
if N >= M**0.5:
    for i in range(M // N, 0, -1):
        if M % i == 0:
            print(i)
            exit()
else:
    for i in range(N, M + 1):
        if M % i == 0:
            print((M // i))
            exit()
print((1))

def div(N):
    ans = []
    for i in range(1, int(N**0.5) + 1):
        if N % i == 0:
            ans.append(i)
            if N // i != i:
                ans.append(N // i)
    ans.sort()
    return ans


N, M = list(map(int, input().split()))
if N == 1:
    print(M)
    exit()
divM = div(M)
for i in range(1, len(divM)):
    if divM[i] > M // N:
        print((divM[i - 1]))
        exit()

+def div(N): +    ans = [] +    for i in range(1, int(N**0.5) + 1): +        if N % i == 0: +            ans.append(i) +            if N // i != i: +                ans.append(N // i) +    ans.sort() +    return ans + + -if N >= M**0.5: -    for i in range(M // N, 0, -1): -        if M % i == 0: -            print(i) -            exit() -else: -    for i in range(N, M + 1): -        if M % i == 0: -            print((M // i)) -            exit() -print((1)) +divM = div(M) +for i in range(1, len(divM)): +    if divM[i] > M // N: +        print((divM[i - 1])) +        exit()