import sys



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

for div in reversed(list(range(1, 1+m//n))):

	if m % div == 0:

		print(div)

		sys.exit()
import sys

from math import sqrt



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

isqrtm = int(sqrt(m))

for revdiv in range(1, 1+isqrtm):

	if m % revdiv == 0:

		div = m // revdiv

		if div <= m//n:

			print(div)

			sys.exit()

for div in range(isqrtm, 0, -1):

	if m % div == 0:

		if div <= m//n:

			print(div)

			sys.exit()

import sys

n, m = list(map(int, input().split()))
for div in reversed(list(range(1, 1 + m // n))):
    if m % div == 0:
        print(div)
        sys.exit()

import sys
from math import sqrt

n, m = list(map(int, input().split()))
isqrtm = int(sqrt(m))
for revdiv in range(1, 1 + isqrtm):
    if m % revdiv == 0:
        div = m // revdiv
        if div <= m // n:
            print(div)
            sys.exit()
for div in range(isqrtm, 0, -1):
    if m % div == 0:
        if div <= m // n:
            print(div)
            sys.exit()

+from math import sqrt -for div in reversed(list(range(1, 1 + m // n))): +isqrtm = int(sqrt(m)) +for revdiv in range(1, 1 + isqrtm): +    if m % revdiv == 0: +        div = m // revdiv +        if div <= m // n: +            print(div) +            sys.exit() +for div in range(isqrtm, 0, -1): -        print(div) -        sys.exit() +        if div <= m // n: +            print(div) +            sys.exit()