def main():

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

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

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

            print(i)

            break





if __name__ == '__main__':

    main()
def main():

    n, m = list(map(int, input().split()))

    f = [1, m]

    i = 2

    while i * i <= m:

        if m % i == 0:

            f.append(i)

            if m != i * i:

                f.append(m // i)

        i += 1

    f.sort()

    answer = 0

    for ff in f:

        if n <= ff:

            answer = m // ff

            break

    print(answer)





if __name__ == '__main__':

    main()



def main():
    N, M = list(map(int, input().split(" ")))
    for i in range(M // N, 0, -1):
        if M % i == 0 and i <= M / N:
            print(i)
            break


if __name__ == "__main__":
    main()

def main():
    n, m = list(map(int, input().split()))
    f = [1, m]
    i = 2
    while i * i <= m:
        if m % i == 0:
            f.append(i)
            if m != i * i:
                f.append(m // i)
        i += 1
    f.sort()
    answer = 0
    for ff in f:
        if n <= ff:
            answer = m // ff
            break
    print(answer)


if __name__ == "__main__":
    main()

-    N, M = list(map(int, input().split(" "))) -    for i in range(M // N, 0, -1): -        if M % i == 0 and i <= M / N: -            print(i) +    n, m = list(map(int, input().split())) +    f = [1, m] +    i = 2 +    while i * i <= m: +        if m % i == 0: +            f.append(i) +            if m != i * i: +                f.append(m // i) +        i += 1 +    f.sort() +    answer = 0 +    for ff in f: +        if n <= ff: +            answer = m // ff +    print(answer)