def is_prime(N):

    if N == 1:

        return False

    for k in range(2, int(N**0.5) + 1):

        if N % k == 0:

            return False

    return True





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

k = 0

if N != 1:

    if is_prime(M):

        print((1))

        exit()

while True:

    if M % (N + k) == 0:

        ans = M // (N+k)

        break

    k += 1

print(ans)
import bisect

def make_divisors(N):

    divisors = []

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

        if N % i == 0:

            divisors.append(i)

            if i != N // i:

                divisors.append(N//i)

    divisors.sort()

    return divisors

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

lst = make_divisors(M)

print((lst[bisect.bisect_right(lst, M//N)-1]))
def is_prime(N):
    if N == 1:
        return False
    for k in range(2, int(N**0.5) + 1):
        if N % k == 0:
            return False
    return True


N, M = list(map(int, input().split()))
k = 0
if N != 1:
    if is_prime(M):
        print((1))
        exit()
while True:
    if M % (N + k) == 0:
        ans = M // (N + k)
        break
    k += 1
print(ans)

import bisect


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


N, M = list(map(int, input().split()))
lst = make_divisors(M)
print((lst[bisect.bisect_right(lst, M // N) - 1]))

-def is_prime(N): -    if N == 1: -        return False -    for k in range(2, int(N**0.5) + 1): -        if N % k == 0: -            return False -    return True +import bisect + + +def make_divisors(N): +    divisors = [] +    for i in range(1, int(N**0.5) + 1): +        if N % i == 0: +            divisors.append(i) +            if i != N // i: +                divisors.append(N // i) +    divisors.sort() +    return divisors -k = 0 -if N != 1: -    if is_prime(M): -        print((1)) -        exit() -while True: -    if M % (N + k) == 0: -        ans = M // (N + k) -        break -    k += 1 -print(ans) +lst = make_divisors(M) +print((lst[bisect.bisect_right(lst, M // N) - 1]))