import sys

# input = sys.stdin.buffer.readline

def getN():

    return int(eval(input()))

def getNM():

    return list(map(int, input().split()))

def getlist():

    return list(map(int, input().split()))

import math

import heapq

import fractions

from collections import defaultdict, Counter, deque

MOD = 10**9 + 7

INF = 10**15



def getyaku(n):

    res = []

    for i in range(1, int(math.sqrt(n)) + 1):

        if n % i == 0:

            res.append(i)

            res.append(n // i)



    return(sorted(list(set(res))))



def factorization(n):

    arr = []

    temp = n

    for i in range(2, int(-(-n**0.5//1))+1):

        if temp%i==0:

            cnt=0

            while temp%i==0:

                cnt+=1

                temp //= i

            arr.append([i, cnt])



    if temp!=1:

        arr.append([temp, 1])



    if arr==[]:

        arr.append([n, 1])



    return arr



def main():

    n,m = getlist()

    arr = getyaku(m)

    for num in arr:

        if num >= n:

            print((m//num))

            return

    print((1))

    # print(arr)

    return



if __name__ == '__main__':

    main()



"""

9999

3



2916

"""
def getN():

    return int(eval(input()))

def getNM():

    return list(map(int, input().split()))

def getList():

    return list(map(int, input().split()))



from collections import defaultdict, deque

from sys import exit

import math

import copy

from bisect import bisect_left, bisect_right

import heapq

import sys

# sys.setrecursionlimit(1000000)

INF = 10 ** 17

MOD = 998244353

def mint(lis):

    return list(map(int, lis))



def bifind(arr_sorted, x):

    idx = bisect_left(arr_sorted, x)

    if idx == len(arr_sorted):

        return False

    if arr_sorted[idx] == x:

        return True

    else:

        return False

def getyaku(n):

    ret = []

    for i in range(1, int(math.sqrt(n) + 1)):

        if n % i == 0:

            ret.append(i)

            ret.append(n // i)



    return ret



def main():

    n, m = getList()

    ans = 0

    for yaku in getyaku(m):

        if m // yaku >= n:

            if ans < yaku:

                ans = yaku

    print(ans)



if __name__ == "__main__":

    main()



import sys

# input = sys.stdin.buffer.readline
def getN():
    return int(eval(input()))


def getNM():
    return list(map(int, input().split()))


def getlist():
    return list(map(int, input().split()))


import math
import heapq
import fractions
from collections import defaultdict, Counter, deque

MOD = 10**9 + 7
INF = 10**15


def getyaku(n):
    res = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            res.append(i)
            res.append(n // i)
    return sorted(list(set(res)))


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-(n**0.5) // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


def main():
    n, m = getlist()
    arr = getyaku(m)
    for num in arr:
        if num >= n:
            print((m // num))
            return
    print((1))
    # print(arr)
    return


if __name__ == "__main__":
    main()
"""
9999
3
2916
"""

def getN():
    return int(eval(input()))


def getNM():
    return list(map(int, input().split()))


def getList():
    return list(map(int, input().split()))


from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
import heapq
import sys

# sys.setrecursionlimit(1000000)
INF = 10**17
MOD = 998244353


def mint(lis):
    return list(map(int, lis))


def bifind(arr_sorted, x):
    idx = bisect_left(arr_sorted, x)
    if idx == len(arr_sorted):
        return False
    if arr_sorted[idx] == x:
        return True
    else:
        return False


def getyaku(n):
    ret = []
    for i in range(1, int(math.sqrt(n) + 1)):
        if n % i == 0:
            ret.append(i)
            ret.append(n // i)
    return ret


def main():
    n, m = getList()
    ans = 0
    for yaku in getyaku(m):
        if m // yaku >= n:
            if ans < yaku:
                ans = yaku
    print(ans)


if __name__ == "__main__":
    main()

-import sys - -# input = sys.stdin.buffer.readline -def getlist(): +def getList(): +from collections import defaultdict, deque +from sys import exit +import copy +from bisect import bisect_left, bisect_right -import fractions -from collections import defaultdict, Counter, deque +import sys -MOD = 10**9 + 7 -INF = 10**15 +# sys.setrecursionlimit(1000000) +INF = 10**17 +MOD = 998244353 + + +def mint(lis): +    return list(map(int, lis)) + + +def bifind(arr_sorted, x): +    idx = bisect_left(arr_sorted, x) +    if idx == len(arr_sorted): +        return False +    if arr_sorted[idx] == x: +        return True +    else: +        return False -    res = [] -    for i in range(1, int(math.sqrt(n)) + 1): +    ret = [] +    for i in range(1, int(math.sqrt(n) + 1)): -            res.append(i) -            res.append(n // i) -    return sorted(list(set(res))) - - -def factorization(n): -    arr = [] -    temp = n -    for i in range(2, int(-(-(n**0.5) // 1)) + 1): -        if temp % i == 0: -            cnt = 0 -            while temp % i == 0: -                cnt += 1 -                temp //= i -            arr.append([i, cnt]) -    if temp != 1: -        arr.append([temp, 1]) -    if arr == []: -        arr.append([n, 1]) -    return arr +            ret.append(i) +            ret.append(n // i) +    return ret -    n, m = getlist() -    arr = getyaku(m) -    for num in arr: -        if num >= n: -            print((m // num)) -            return -    print((1)) -    # print(arr) -    return +    n, m = getList() +    ans = 0 +    for yaku in getyaku(m): +        if m // yaku >= n: +            if ans < yaku: +                ans = yaku +    print(ans) -""" -9999 -3 -2916 -"""