def divisors(N):

    i = 1

    U = int(N ** 0.5)

    res = []

    for i in range(1, U):

        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):

    U = int(N ** 0.5)

    res = []

    for i in range(1, U):

        if N % i == 0:

            res += [i, N // i]

    if N % U == 0:

        res.append(U)

    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):
    i = 1
    U = int(N**0.5)
    res = []
    for i in range(1, U):
        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):
    U = int(N**0.5)
    res = []
    for i in range(1, U):
        if N % i == 0:
            res += [i, N // i]
    if N % U == 0:
        res.append(U)
    res.sort()
    return res


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

-    i = 1 -    if N % i == 0: -        res.append(i) +    if N % U == 0: +        res.append(U)