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

ceil = M // N

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

    tmp = M - i * (N - 1)

    if tmp > 0 and tmp % i == 0:

        print(i)

        break

def make_divisors(n):

    divisors = []

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

        if n % i == 0:

            divisors.append([i,n//i])

            if i != n // i:

                divisors.append([n//i, i])



    # divisors.sort()

    return divisors



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

ceil = M // N

divisors = make_divisors(M)

divisors.sort(reverse=True)

for i,j in divisors:

    if j >= N:

        print(i)

        break

N, M = list(map(int, input().split()))
ceil = M // N
for i in range(1, ceil + 1)[::-1]:
    tmp = M - i * (N - 1)
    if tmp > 0 and tmp % i == 0:
        print(i)
        break

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


N, M = list(map(int, input().split()))
ceil = M // N
divisors = make_divisors(M)
divisors.sort(reverse=True)
for i, j in divisors:
    if j >= N:
        print(i)
        break

+def make_divisors(n): +    divisors = [] +    for i in range(1, int(n**0.5) + 1): +        if n % i == 0: +            divisors.append([i, n // i]) +            if i != n // i: +                divisors.append([n // i, i]) +    # divisors.sort() +    return divisors + + -for i in range(1, ceil + 1)[::-1]: -    tmp = M - i * (N - 1) -    if tmp > 0 and tmp % i == 0: +divisors = make_divisors(M) +divisors.sort(reverse=True) +for i, j in divisors: +    if j >= N: