def main():

    import sys

    input = sys.stdin.readline

    sys.setrecursionlimit(10**7)

    from collections import Counter, deque

    #from collections import defaultdict

    from itertools import combinations, permutations, accumulate, groupby

    #from itertools import product

    from bisect import bisect_left,bisect_right

    from heapq import heapify, heappop, heappush

    from math import floor, ceil

    #from operator import itemgetter



    #inf = 10**17

    #mod = 10**9 + 7



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

    a = m // n

    for i in range(a, 0, -1):

        if m % i == 0:

            print(i)

            break



if __name__ == '__main__':

    main()
def main():

    import sys

    input = sys.stdin.readline

    sys.setrecursionlimit(10**7)

    from collections import Counter, deque

    #from collections import defaultdict

    from itertools import combinations, permutations, accumulate, groupby

    #from itertools import product

    from bisect import bisect_left,bisect_right

    from heapq import heapify, heappop, heappush

    from math import floor, ceil

    #from operator import itemgetter



    #inf = 10**17

    #mod = 10**9 + 7



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

    def yakusuu(N):

        n = int(N**.5)+1

        res1 = []

        res2 = []

        for i in range(1, n):

            if N%i==0:

                res1.append(i)

                if N!=i**2:

                    res2.append(N//i)

        res2.reverse()

        return res1+res2

    a = yakusuu(m)

    a.sort(reverse=True)

    for i in a:

        if m//i >= n:

            print(i)

            break



if __name__ == '__main__':

    main()
def main():
    import sys

    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque

    # from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby

    # from itertools import product
    from bisect import bisect_left, bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil

    # from operator import itemgetter
    # inf = 10**17
    # mod = 10**9 + 7
    n, m = list(map(int, input().split()))
    a = m // n
    for i in range(a, 0, -1):
        if m % i == 0:
            print(i)
            break


if __name__ == "__main__":
    main()

def main():
    import sys

    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque

    # from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby

    # from itertools import product
    from bisect import bisect_left, bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil

    # from operator import itemgetter
    # inf = 10**17
    # mod = 10**9 + 7
    n, m = list(map(int, input().split()))

    def yakusuu(N):
        n = int(N**0.5) + 1
        res1 = []
        res2 = []
        for i in range(1, n):
            if N % i == 0:
                res1.append(i)
                if N != i**2:
                    res2.append(N // i)
        res2.reverse()
        return res1 + res2

    a = yakusuu(m)
    a.sort(reverse=True)
    for i in a:
        if m // i >= n:
            print(i)
            break


if __name__ == "__main__":
    main()

-    a = m // n -    for i in range(a, 0, -1): -        if m % i == 0: + +    def yakusuu(N): +        n = int(N**0.5) + 1 +        res1 = [] +        res2 = [] +        for i in range(1, n): +            if N % i == 0: +                res1.append(i) +                if N != i**2: +                    res2.append(N // i) +        res2.reverse() +        return res1 + res2 + +    a = yakusuu(m) +    a.sort(reverse=True) +    for i in a: +        if m // i >= n: