from itertools import product



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



max_ans = M // N



ans = 1

tmp = 2

tmpM = M

max_prime = int(M ** 0.5)

all_list = []

i = -1

k = 0

div = 2

while tmpM != 1:

    if tmpM % div == 0:

        tmpM = tmpM // div

        if k == 0:

            i += 1

            all_list.append(set())

            all_list[i].add(div ** k)

            k += 1

        all_list[i].add(div ** k)

        k += 1



    else:

        k = 0

        if div == 2:

            div = 3

        elif div > max_prime:

            div = tmpM

        else:

            div += 2



if all_list == []:

    print((1))

    exit()



# print(all_list)

ans = 1



for div_tuple in product(*all_list):

    tmp = 1

    for k in div_tuple:

        tmp *= k

        if tmp > max_ans:

            break

    else:

        ans = max(ans, tmp)



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



max_ans = M // N



ans = 1



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

    if M % n != 0:

        continue



    if n <= max_ans:

        ans = max(ans, n)

    if M // n <= max_ans:

        ans = max(ans, M // n)



print(ans)
from itertools import product

N, M = list(map(int, input().split()))
max_ans = M // N
ans = 1
tmp = 2
tmpM = M
max_prime = int(M**0.5)
all_list = []
i = -1
k = 0
div = 2
while tmpM != 1:
    if tmpM % div == 0:
        tmpM = tmpM // div
        if k == 0:
            i += 1
            all_list.append(set())
            all_list[i].add(div**k)
            k += 1
        all_list[i].add(div**k)
        k += 1
    else:
        k = 0
        if div == 2:
            div = 3
        elif div > max_prime:
            div = tmpM
        else:
            div += 2
if all_list == []:
    print((1))
    exit()
# print(all_list)
ans = 1
for div_tuple in product(*all_list):
    tmp = 1
    for k in div_tuple:
        tmp *= k
        if tmp > max_ans:
            break
    else:
        ans = max(ans, tmp)
print(ans)

N, M = list(map(int, input().split()))
max_ans = M // N
ans = 1
for n in range(1, int(M**0.5) + 1):
    if M % n != 0:
        continue
    if n <= max_ans:
        ans = max(ans, n)
    if M // n <= max_ans:
        ans = max(ans, M // n)
print(ans)

-from itertools import product - -tmp = 2 -tmpM = M -max_prime = int(M**0.5) -all_list = [] -i = -1 -k = 0 -div = 2 -while tmpM != 1: -    if tmpM % div == 0: -        tmpM = tmpM // div -        if k == 0: -            i += 1 -            all_list.append(set()) -            all_list[i].add(div**k) -            k += 1 -        all_list[i].add(div**k) -        k += 1 -    else: -        k = 0 -        if div == 2: -            div = 3 -        elif div > max_prime: -            div = tmpM -        else: -            div += 2 -if all_list == []: -    print((1)) -    exit() -# print(all_list) -ans = 1 -for div_tuple in product(*all_list): -    tmp = 1 -    for k in div_tuple: -        tmp *= k -        if tmp > max_ans: -            break -    else: -        ans = max(ans, tmp) +for n in range(1, int(M**0.5) + 1): +    if M % n != 0: +        continue +    if n <= max_ans: +        ans = max(ans, n) +    if M // n <= max_ans: +        ans = max(ans, M // n)