from bisect import bisect_left



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



st = set()

i = 1

while i * i <= m:

    if m % i == 0:

        st.add(i)

        st.add(m // i)

    i += 1



divs = tuple(sorted(st))

i = bisect_left(divs, n)

print((m // divs[i]))

def main():

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



    st = {1, M}

    d = 2

    while d * d <= M:

        if M % d == 0:

            st.add(d)

            st.add(M // d)

        d += 1



    ans = 1

    for d in st:

        if d >= N:

            e = M // d

            ans = max(ans, e)

    print(ans)





if __name__ == '__main__':

    main()

from bisect import bisect_left

n, m = list(map(int, input().split()))
st = set()
i = 1
while i * i <= m:
    if m % i == 0:
        st.add(i)
        st.add(m // i)
    i += 1
divs = tuple(sorted(st))
i = bisect_left(divs, n)
print((m // divs[i]))

def main():
    N, M = list(map(int, input().split()))
    st = {1, M}
    d = 2
    while d * d <= M:
        if M % d == 0:
            st.add(d)
            st.add(M // d)
        d += 1
    ans = 1
    for d in st:
        if d >= N:
            e = M // d
            ans = max(ans, e)
    print(ans)


if __name__ == "__main__":
    main()

-from bisect import bisect_left +def main(): +    N, M = list(map(int, input().split())) +    st = {1, M} +    d = 2 +    while d * d <= M: +        if M % d == 0: +            st.add(d) +            st.add(M // d) +        d += 1 +    ans = 1 +    for d in st: +        if d >= N: +            e = M // d +            ans = max(ans, e) +    print(ans) -n, m = list(map(int, input().split())) -st = set() -i = 1 -while i * i <= m: -    if m % i == 0: -        st.add(i) -        st.add(m // i) -    i += 1 -divs = tuple(sorted(st)) -i = bisect_left(divs, n) -print((m // divs[i])) + +if __name__ == "__main__": +    main()