def divisors(N):

    res = []

    i = 1

    while i * i < N:

        if N % i == 0:

            res += [i, N // i]

        i += 1

    if N % i == 0:

        res.append(i)

    res.sort()

    return res



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

print((max(d for d in divisors(M) if d * N <= M)))

def divisors(N):

    res = []

    i = 1

    for i in range(1, int(N ** 0.5)):

        if N % i == 0:

            res += [i, N // i]

    if N % i == 0:

        res.append(i)

    res.sort()

    return res



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

print((max(d for d in divisors(M) if d * N <= M)))

def divisors(N):
    res = []
    i = 1
    while i * i < N:
        if N % i == 0:
            res += [i, N // i]
        i += 1
    if N % i == 0:
        res.append(i)
    res.sort()
    return res


N, M = list(map(int, input().split()))
print((max(d for d in divisors(M) if d * N <= M)))

def divisors(N):
    res = []
    i = 1
    for i in range(1, int(N**0.5)):
        if N % i == 0:
            res += [i, N // i]
    if N % i == 0:
        res.append(i)
    res.sort()
    return res


N, M = list(map(int, input().split()))
print((max(d for d in divisors(M) if d * N <= M)))

-    while i * i < N: +    for i in range(1, int(N**0.5)): -        i += 1