from collections import Counter

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



def factorize(m):

    c = Counter()

    t = 2

    while t**2 <= m:

        if m % t:

            t += 1

            continue

        while not m%t:

            c[t] += 1

            m //= t

    if m > 1:

        c[m] += 1

    return c

yakusu = [1]

for key, value in list(factorize(m).items()):

    next_yakusu = []

    for i in range(value+1):

        for j in yakusu:

            next_yakusu.append(j*key**i)

    yakusu = next_yakusu



ans = 1

for i in yakusu:

    if n <= m//i:

        ans = max(ans, i)

print(ans)
from math import sqrt

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

ans = 1

for i in range(int(sqrt(m))):

    if m%(i+1)==0:

        if n <= m//(i+1) : ans= max(ans, i+1)

        if n <= i+1 : ans = max(ans,m//(i+1))

print(ans)
from collections import Counter

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


def factorize(m):
    c = Counter()
    t = 2
    while t**2 <= m:
        if m % t:
            t += 1
            continue
        while not m % t:
            c[t] += 1
            m //= t
    if m > 1:
        c[m] += 1
    return c


yakusu = [1]
for key, value in list(factorize(m).items()):
    next_yakusu = []
    for i in range(value + 1):
        for j in yakusu:
            next_yakusu.append(j * key**i)
    yakusu = next_yakusu
ans = 1
for i in yakusu:
    if n <= m // i:
        ans = max(ans, i)
print(ans)

from math import sqrt

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

-from collections import Counter +from math import sqrt - - -def factorize(m): -    c = Counter() -    t = 2 -    while t**2 <= m: -        if m % t: -            t += 1 -            continue -        while not m % t: -            c[t] += 1 -            m //= t -    if m > 1: -        c[m] += 1 -    return c - - -yakusu = [1] -for key, value in list(factorize(m).items()): -    next_yakusu = [] -    for i in range(value + 1): -        for j in yakusu: -            next_yakusu.append(j * key**i) -    yakusu = next_yakusu -for i in yakusu: -    if n <= m // i: -        ans = max(ans, i) +for i in range(int(sqrt(m))): +    if m % (i + 1) == 0: +        if n <= m // (i + 1): +            ans = max(ans, i + 1) +        if n <= i + 1: +            ans = max(ans, m // (i + 1))