def divisors(N):

    res = []

    i = 1

    while i * i <= N:

        q, r = N // i, N % i

        if r == 0:

            res.append(i)

            if i != q:

                res.append(q)

        i += 1

    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.append(i)

            q = N // i

            if i != q:

                res.append(q)

        i += 1

    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:
        q, r = N // i, N % i
        if r == 0:
            res.append(i)
            if i != q:
                res.append(q)
        i += 1
    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.append(i)
            q = N // i
            if i != q:
                res.append(q)
        i += 1
    res.sort()
    return res


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

-        q, r = N // i, N % i -        if r == 0: +        if N % i == 0: +            q = N // i