from collections import Counter



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





def factorize(n):

    if n == 1:

        return [1]



    i, factors = 2, []

    while i * i <= n:

        while n % i == 0:

            n //= i

            factors.append(i)

        i += 1

    if n > 1:

        factors.append(n)

    return factors





c = Counter(factorize(M))

a = [1]

for k, v in list(c.items()):

    tmp = []

    for x in a:

        for i in range(v + 1):

            tmp.append(x * (k**i))

    a = list(set(a) | set(tmp))



ans = 0

for x in a:

    y = M // x

    if N <= y:

        ans = max(ans, x)

print(ans)

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





def make_divisors(n):

    i, divisors = 1, []

    while i * i <= n:

        if n % i == 0:

            divisors.append(i)

            if i != n // i:

                divisors.append(n // i)

        i += 1

    return divisors





ans = 0

for x in make_divisors(M):

    if N <= M // x:

        ans = max(ans, x)

print(ans)

from collections import Counter

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


def factorize(n):
    if n == 1:
        return [1]
    i, factors = 2, []
    while i * i <= n:
        while n % i == 0:
            n //= i
            factors.append(i)
        i += 1
    if n > 1:
        factors.append(n)
    return factors


c = Counter(factorize(M))
a = [1]
for k, v in list(c.items()):
    tmp = []
    for x in a:
        for i in range(v + 1):
            tmp.append(x * (k**i))
    a = list(set(a) | set(tmp))
ans = 0
for x in a:
    y = M // x
    if N <= y:
        ans = max(ans, x)
print(ans)

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


def make_divisors(n):
    i, divisors = 1, []
    while i * i <= n:
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
        i += 1
    return divisors


ans = 0
for x in make_divisors(M):
    if N <= M // x:
        ans = max(ans, x)
print(ans)

-from collections import Counter - -def factorize(n): -    if n == 1: -        return [1] -    i, factors = 2, [] +def make_divisors(n): +    i, divisors = 1, [] -        while n % i == 0: -            n //= i -            factors.append(i) +        if n % i == 0: +            divisors.append(i) +            if i != n // i: +                divisors.append(n // i) -    if n > 1: -        factors.append(n) -    return factors +    return divisors -c = Counter(factorize(M)) -a = [1] -for k, v in list(c.items()): -    tmp = [] -    for x in a: -        for i in range(v + 1): -            tmp.append(x * (k**i)) -    a = list(set(a) | set(tmp)) -for x in a: -    y = M // x -    if N <= y: +for x in make_divisors(M): +    if N <= M // x: