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

def solv(N, M):

    d = M//N

    for i in range(d+1)[::-1]:

        if M%i == 0:

            return i

print((solv(N, M)))
n, m = list(map(int, input().split(" ")))



ds = [x for x in range(1, int(m**.5)+1) if m%x==0]

ds = ds + [m//x for x in ds]

ds = [x for x in ds if x<=m//n]

print((max(ds)))
N, M = list(map(int, input().split(" ")))


def solv(N, M):
    d = M // N
    for i in range(d + 1)[::-1]:
        if M % i == 0:
            return i


print((solv(N, M)))

n, m = list(map(int, input().split(" ")))
ds = [x for x in range(1, int(m**0.5) + 1) if m % x == 0]
ds = ds + [m // x for x in ds]
ds = [x for x in ds if x <= m // n]
print((max(ds)))

-N, M = list(map(int, input().split(" "))) - - -def solv(N, M): -    d = M // N -    for i in range(d + 1)[::-1]: -        if M % i == 0: -            return i - - -print((solv(N, M))) +n, m = list(map(int, input().split(" "))) +ds = [x for x in range(1, int(m**0.5) + 1) if m % x == 0] +ds = ds + [m // x for x in ds] +ds = [x for x in ds if x <= m // n] +print((max(ds)))