import collections

import itertools

import math





def eratosthenes(n):

    sieve = [True for _ in range(n + 1)]

    sieve[0] = False

    sieve[1] = False



    def _update(p):

        if sieve[p]:

            for i in range(p * 2, n + 1, p):

                sieve[i] = False



    _update(2)

    p = 3

    while p * p <= n:

        _update(p)

        p += 2

    return sieve





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

m2 = math.ceil(math.sqrt(m)) + 1

sieve = eratosthenes(m2)

counter = collections.Counter()



mm = m

for k in range(2, m2):

    if sieve[k] and m % k == 0:

        while mm % k == 0:

            mm //= k

            counter[k] += 1

if mm > 1:

    counter[mm] += 1



es = [list(range(k + 1)) for k in list(counter.values())]

res = 1

for ks in itertools.product(*es):

    x = 1

    for p, k in zip(list(counter.keys()), ks):

        x *= p**k

    if x <= m // n:

        res = max(res, x)

print(res)
import math



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

mm = m // n

res = []

for k in range(int(math.sqrt(m)), 0, -1):

    if m % k == 0:

        if k > mm:

            continue

        if m // k <= mm:

            k = m // k

        res.append(k)

print((max(res)))
import collections
import itertools
import math


def eratosthenes(n):
    sieve = [True for _ in range(n + 1)]
    sieve[0] = False
    sieve[1] = False

    def _update(p):
        if sieve[p]:
            for i in range(p * 2, n + 1, p):
                sieve[i] = False

    _update(2)
    p = 3
    while p * p <= n:
        _update(p)
        p += 2
    return sieve


n, m = list(map(int, input().split()))
m2 = math.ceil(math.sqrt(m)) + 1
sieve = eratosthenes(m2)
counter = collections.Counter()
mm = m
for k in range(2, m2):
    if sieve[k] and m % k == 0:
        while mm % k == 0:
            mm //= k
            counter[k] += 1
if mm > 1:
    counter[mm] += 1
es = [list(range(k + 1)) for k in list(counter.values())]
res = 1
for ks in itertools.product(*es):
    x = 1
    for p, k in zip(list(counter.keys()), ks):
        x *= p**k
    if x <= m // n:
        res = max(res, x)
print(res)

import math

n, m = list(map(int, input().split()))
mm = m // n
res = []
for k in range(int(math.sqrt(m)), 0, -1):
    if m % k == 0:
        if k > mm:
            continue
        if m // k <= mm:
            k = m // k
        res.append(k)
print((max(res)))

-import collections -import itertools - -def eratosthenes(n): -    sieve = [True for _ in range(n + 1)] -    sieve[0] = False -    sieve[1] = False - -    def _update(p): -        if sieve[p]: -            for i in range(p * 2, n + 1, p): -                sieve[i] = False - -    _update(2) -    p = 3 -    while p * p <= n: -        _update(p) -        p += 2 -    return sieve - - -m2 = math.ceil(math.sqrt(m)) + 1 -sieve = eratosthenes(m2) -counter = collections.Counter() -mm = m -for k in range(2, m2): -    if sieve[k] and m % k == 0: -        while mm % k == 0: -            mm //= k -            counter[k] += 1 -if mm > 1: -    counter[mm] += 1 -es = [list(range(k + 1)) for k in list(counter.values())] -res = 1 -for ks in itertools.product(*es): -    x = 1 -    for p, k in zip(list(counter.keys()), ks): -        x *= p**k -    if x <= m // n: -        res = max(res, x) -print(res) +mm = m // n +res = [] +for k in range(int(math.sqrt(m)), 0, -1): +    if m % k == 0: +        if k > mm: +            continue +        if m // k <= mm: +            k = m // k +        res.append(k) +print((max(res)))