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

amax = 1

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

    if M%i==0:

        a = i

        b = M//i

        if b>=N:

            amax = max(amax,a)

        a,b = b,a

        if b>=N:

            amax = max(amax,a)

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

g = 0

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

    if M%i==0:

        a = i

        b = M//i

        if a>=N:

            g = max(g,b)

        if b>=N:

            g = max(g,a)

print(g)
N, M = list(map(int, input().split()))
amax = 1
for i in range(1, int(M**0.5) + 1):
    if M % i == 0:
        a = i
        b = M // i
        if b >= N:
            amax = max(amax, a)
        a, b = b, a
        if b >= N:
            amax = max(amax, a)
print(amax)

N, M = list(map(int, input().split()))
g = 0
for i in range(1, int(M**0.5) + 1):
    if M % i == 0:
        a = i
        b = M // i
        if a >= N:
            g = max(g, b)
        if b >= N:
            g = max(g, a)
print(g)

-amax = 1 +g = 0 +        if a >= N: +            g = max(g, b) -            amax = max(amax, a) -        a, b = b, a -        if b >= N: -            amax = max(amax, a) -print(amax) +            g = max(g, a) +print(g)