import sys

stdin = sys.stdin

 

sys.setrecursionlimit(10**5) 

 

def li(): return list(map(int, stdin.readline().split()))

def li_(): return [int(x)-1 for x in stdin.readline().split()]

def lf(): return list(map(float, stdin.readline().split()))

def ls(): return stdin.readline().split()

def ns(): return stdin.readline().rstrip()

def lc(): return list(ns())

def ni(): return int(stdin.readline())

def nf(): return float(stdin.readline())



n,m = li()



# mの約数を求める

i = 1

div = []

while i*i <= m:

    if m%i == 0:

        div.append(i)

        div.append(m//i)

    i += 1

    

ans = 1

for d in div:

    if m//d >= n:

        ans = max(ans, d)

        

print(ans)
import sys

stdin = sys.stdin



sys.setrecursionlimit(10**5)



def li(): return list(map(int, stdin.readline().split()))

def li_(): return [int(x)-1 for x in stdin.readline().split()]

def lf(): return list(map(float, stdin.readline().split()))

def ls(): return stdin.readline().split()

def ns(): return stdin.readline().rstrip()

def lc(): return list(ns())

def ni(): return int(stdin.readline())

def nf(): return float(stdin.readline())



def divisors(m: int):

    i = 1

    div = []

    while i*i <= m:

        if m%i == 0:

            div.append(i)

            div.append(m//i)

        i += 1

        

    return list(set(div))



n,m = li()



divs = divisors(m)



ans = 1

for di in divs:

    if n*di <= m:

        ans = max(ans, di)



print(ans)
import sys

stdin = sys.stdin
sys.setrecursionlimit(10**5)


def li():
    return list(map(int, stdin.readline().split()))


def li_():
    return [int(x) - 1 for x in stdin.readline().split()]


def lf():
    return list(map(float, stdin.readline().split()))


def ls():
    return stdin.readline().split()


def ns():
    return stdin.readline().rstrip()


def lc():
    return list(ns())


def ni():
    return int(stdin.readline())


def nf():
    return float(stdin.readline())


n, m = li()
# mの約数を求める
i = 1
div = []
while i * i <= m:
    if m % i == 0:
        div.append(i)
        div.append(m // i)
    i += 1
ans = 1
for d in div:
    if m // d >= n:
        ans = max(ans, d)
print(ans)

import sys

stdin = sys.stdin
sys.setrecursionlimit(10**5)


def li():
    return list(map(int, stdin.readline().split()))


def li_():
    return [int(x) - 1 for x in stdin.readline().split()]


def lf():
    return list(map(float, stdin.readline().split()))


def ls():
    return stdin.readline().split()


def ns():
    return stdin.readline().rstrip()


def lc():
    return list(ns())


def ni():
    return int(stdin.readline())


def nf():
    return float(stdin.readline())


def divisors(m: int):
    i = 1
    div = []
    while i * i <= m:
        if m % i == 0:
            div.append(i)
            div.append(m // i)
        i += 1
    return list(set(div))


n, m = li()
divs = divisors(m)
ans = 1
for di in divs:
    if n * di <= m:
        ans = max(ans, di)
print(ans)

+def divisors(m: int): +    i = 1 +    div = [] +    while i * i <= m: +        if m % i == 0: +            div.append(i) +            div.append(m // i) +        i += 1 +    return list(set(div)) + + -# mの約数を求める -i = 1 -div = [] -while i * i <= m: -    if m % i == 0: -        div.append(i) -        div.append(m // i) -    i += 1 +divs = divisors(m) -for d in div: -    if m // d >= n: -        ans = max(ans, d) +for di in divs: +    if n * di <= m: +        ans = max(ans, di)