import sys



read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline



in_n = lambda: int(readline())

in_nn = lambda: list(map(int, readline().split()))

in_s = lambda: readline().rstrip().decode('utf-8')





def main():

    N, M = in_nn()



    ans = 1

    inf = M // N + 1

    for i in range(inf, 1, -1):

        if i * N <= M and M % i == 0:

            ans = i

            break



    print(ans)





if __name__ == '__main__':

    main()

import sys



read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline



in_n = lambda: int(readline())

in_nn = lambda: list(map(int, readline().split()))

in_s = lambda: readline().rstrip().decode('utf-8')





def make_divisors(n):

    lower_divisors, upper_divisors = [], []

    i = 1

    while i * i <= n:

        if n % i == 0:

            lower_divisors.append(i)

            if i != n // i:

                upper_divisors.append(n // i)

        i += 1

    return lower_divisors + upper_divisors[::-1]





def main():

    N, M = in_nn()



    ans = 1

    for i in sorted(make_divisors(M), reverse=True):

        if i * N <= M and M % i == 0:

            ans = i

            break



    print(ans)





if __name__ == '__main__':

    main()

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
in_n = lambda: int(readline())
in_nn = lambda: list(map(int, readline().split()))
in_s = lambda: readline().rstrip().decode("utf-8")


def main():
    N, M = in_nn()
    ans = 1
    inf = M // N + 1
    for i in range(inf, 1, -1):
        if i * N <= M and M % i == 0:
            ans = i
            break
    print(ans)


if __name__ == "__main__":
    main()

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
in_n = lambda: int(readline())
in_nn = lambda: list(map(int, readline().split()))
in_s = lambda: readline().rstrip().decode("utf-8")


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def main():
    N, M = in_nn()
    ans = 1
    for i in sorted(make_divisors(M), reverse=True):
        if i * N <= M and M % i == 0:
            ans = i
            break
    print(ans)


if __name__ == "__main__":
    main()

+def make_divisors(n): +    lower_divisors, upper_divisors = [], [] +    i = 1 +    while i * i <= n: +        if n % i == 0: +            lower_divisors.append(i) +            if i != n // i: +                upper_divisors.append(n // i) +        i += 1 +    return lower_divisors + upper_divisors[::-1] + + -    inf = M // N + 1 -    for i in range(inf, 1, -1): +    for i in sorted(make_divisors(M), reverse=True):