from collections import Counter

import sys

sys.setrecursionlimit(10 ** 6)





def factorization(n):

    arr = Counter()

    temp = n

    for i in range(2, int(-(-n**0.5 // 1)) + 1):

        if temp % i == 0:

            cnt = 0

            while temp % i == 0:

                cnt += 1

                temp //= i

            arr[i] = cnt



    if temp != 1:

        arr[temp] = 1



    if len(list(arr.keys())) == 0 and n != 1:

        arr[n] = 1



    return arr





def dfs(i, x):

    global N, M, ans

    if i == len(primeKeys):

        if M // x >= N:

            ans = max(ans, x)

    else:

        for j in range(primes[primeKeys[i]] + 1):

            nx = x * (primeKeys[i] ** j)

            if M // nx >= N:

                dfs(i + 1, nx)

            else:

                break





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

primes = factorization(M)

# primeList = list(primes.elements())

primeKeys = list(primes.keys())



ans = 1

dfs(0, 1)



print(ans)

from math import sqrt





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



ans = 1

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

    if M % i == 0:

        j = M // i

        if M / N >= j:

            ans = max(ans, j)

        elif M / N >= i:

            ans = max(ans, i)



print(ans)

from collections import Counter
import sys

sys.setrecursionlimit(10**6)


def factorization(n):
    arr = Counter()
    temp = n
    for i in range(2, int(-(-(n**0.5) // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if len(list(arr.keys())) == 0 and n != 1:
        arr[n] = 1
    return arr


def dfs(i, x):
    global N, M, ans
    if i == len(primeKeys):
        if M // x >= N:
            ans = max(ans, x)
    else:
        for j in range(primes[primeKeys[i]] + 1):
            nx = x * (primeKeys[i] ** j)
            if M // nx >= N:
                dfs(i + 1, nx)
            else:
                break


N, M = list(map(int, input().split()))
primes = factorization(M)
# primeList = list(primes.elements())
primeKeys = list(primes.keys())
ans = 1
dfs(0, 1)
print(ans)

from math import sqrt

N, M = list(map(int, input().split()))
ans = 1
for i in range(1, int(sqrt(M)) + 1):
    if M % i == 0:
        j = M // i
        if M / N >= j:
            ans = max(ans, j)
        elif M / N >= i:
            ans = max(ans, i)
print(ans)

-from collections import Counter -import sys - -sys.setrecursionlimit(10**6) - - -def factorization(n): -    arr = Counter() -    temp = n -    for i in range(2, int(-(-(n**0.5) // 1)) + 1): -        if temp % i == 0: -            cnt = 0 -            while temp % i == 0: -                cnt += 1 -                temp //= i -            arr[i] = cnt -    if temp != 1: -        arr[temp] = 1 -    if len(list(arr.keys())) == 0 and n != 1: -        arr[n] = 1 -    return arr - - -def dfs(i, x): -    global N, M, ans -    if i == len(primeKeys): -        if M // x >= N: -            ans = max(ans, x) -    else: -        for j in range(primes[primeKeys[i]] + 1): -            nx = x * (primeKeys[i] ** j) -            if M // nx >= N: -                dfs(i + 1, nx) -            else: -                break - +from math import sqrt -primes = factorization(M) -# primeList = list(primes.elements()) -primeKeys = list(primes.keys()) -dfs(0, 1) +for i in range(1, int(sqrt(M)) + 1): +    if M % i == 0: +        j = M // i +        if M / N >= j: +            ans = max(ans, j) +        elif M / N >= i: +            ans = max(ans, i)