import copy

def cd_generator(num):

    ans=[]

    for i in range(1,10000000):

        if num%i==0:

            ans.append(i)

    temp=copy.deepcopy(ans)

    temp.reverse()

    for ele in temp:

        ans.append(num//ele)

    return ans

def main():

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

    array=cd_generator(m)

    ans=0

    for ele in array:

        if m//ele>=n:

            ans=max(ans,ele)

    print(ans)

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]

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

array=make_divisors(m)

array.reverse()

for ele in array:

    if m//ele>=n:

        print(ele)

        exit()

import copy


def cd_generator(num):
    ans = []
    for i in range(1, 10000000):
        if num % i == 0:
            ans.append(i)
    temp = copy.deepcopy(ans)
    temp.reverse()
    for ele in temp:
        ans.append(num // ele)
    return ans


def main():
    n, m = list(map(int, input().split()))
    array = cd_generator(m)
    ans = 0
    for ele in array:
        if m // ele >= n:
            ans = max(ans, ele)
    print(ans)


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]


n, m = list(map(int, input().split()))
array = make_divisors(m)
array.reverse()
for ele in array:
    if m // ele >= n:
        print(ele)
        exit()

-import copy +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 cd_generator(num): -    ans = [] -    for i in range(1, 10000000): -        if num % i == 0: -            ans.append(i) -    temp = copy.deepcopy(ans) -    temp.reverse() -    for ele in temp: -        ans.append(num // ele) -    return ans - - -def main(): -    n, m = list(map(int, input().split())) -    array = cd_generator(m) -    ans = 0 -    for ele in array: -        if m // ele >= n: -            ans = max(ans, ele) -    print(ans) - - -main() +n, m = list(map(int, input().split())) +array = make_divisors(m) +array.reverse() +for ele in array: +    if m // ele >= n: +        print(ele) +        exit()