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



def solution():

    if M-N < M//N:

        for n in range(N, M+1):

            if M%n==0:

                return M//n

    else:

        for m in range(M//N, 0, -1):

            if M%m==0:

                return m



print((solution()))

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



def solution():

    answer = 1

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

        if M%i ==0:

            if M//i>=N:

                answer = max(answer , i)

            if i>=N:

                answer = max(answer, M//i)

    return answer



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


def solution():
    if M - N < M // N:
        for n in range(N, M + 1):
            if M % n == 0:
                return M // n
    else:
        for m in range(M // N, 0, -1):
            if M % m == 0:
                return m


print((solution()))

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


def solution():
    answer = 1
    for i in range(1, int(M**0.5) + 1):
        if M % i == 0:
            if M // i >= N:
                answer = max(answer, i)
            if i >= N:
                answer = max(answer, M // i)
    return answer


print((solution()))

-    if M - N < M // N: -        for n in range(N, M + 1): -            if M % n == 0: -                return M // n -    else: -        for m in range(M // N, 0, -1): -            if M % m == 0: -                return m +    answer = 1 +    for i in range(1, int(M**0.5) + 1): +        if M % i == 0: +            if M // i >= N: +                answer = max(answer, i) +            if i >= N: +                answer = max(answer, M // i) +    return answer