You are given integers N and M.
Consider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.

-----Constraints-----
 - All values in input are integers.
 - 1 \leq N \leq 10^5
 - N \leq M \leq 10^9

-----Input-----
Input is given from Standard Input in the following format:
N M

-----Output-----
Print the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.

-----Sample Input-----
3 14

-----Sample Output-----
2

Consider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.

Difficulty: MEDIUM

Solutions:
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) = map(int, input().split())
ans = 0
for i in make_divisors(m):
	if m // i >= n:
		ans = i
print(ans)


def resolve():
	(N, M) = map(int, input().split())
	ans = 1
	for A in range(1, int(M ** 0.5) + 1):
		if M % A != 0:
			continue
		B = M // A
		if N * A <= M:
			ans = max(ans, A)
		if N * B <= M:
			ans = max(ans, B)
	print(ans)

def __starting_point():
	resolve()
__starting_point()


import sys
import math
from collections import deque
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda : sys.stdin.readline().strip()
NI = lambda : int(input())
NMI = lambda : map(int, input().split())
NLI = lambda : list(NMI())
SI = lambda : input()

def make_grid(h, w, num):
	return [[int(num)] * w for _ in range(h)]

def main():
	(N, M) = NMI()
	yak = set()
	i = 1
	while i * i <= M:
		if M % i == 0:
			yak.add(i)
			yak.add(M // i)
		i += 1
	yak = sorted(list(yak), reverse=True)
	for y in yak:
		if y * N <= M:
			print(y)
			return

def __starting_point():
	main()
__starting_point()


def main():
	(N, M) = map(int, input().split(' '))
	for i in range(M // N, 0, -1):
		if M % i == 0 and i <= M / N:
			print(i)
			break
main()


def divisor(n):
	i = 1
	res = set()
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.add(i)
			res.add(n // i)
	return res

def main():
	(n, m) = map(int, input().split())
	md = list(divisor(m))
	md.sort(reverse=True)
	for i in md:
		if i * n <= m:
			print(i)
			return

def __starting_point():
	main()
__starting_point()


def f():
	(n, m) = map(int, input().split())
	for i in range(m // n, 0, -1):
		if m % i == 0:
			break
	return i
print(f())


from collections import deque
(N, M) = list(map(int, input().split()))
a = deque()
b = deque()
for i in range(1, int(M ** (1 / 2)) + 1):
	if M % i == 0:
		a.appendleft(i)
		b.append(M // i)
b.extend(a)
for i in b:
	m = M // i
	if m >= N:
		print(i)
		break


import math
(n, m) = map(int, input().split())
fact = []
ans = 1
MAX = int(math.sqrt(m)) + 1
for i in range(1, MAX):
	if m % i == 0:
		fact.append(i)
		if i != m // i:
			fact.append(m // i)
fact.sort()
for x in fact:
	if m < n * x:
		break
	ans = x
print(ans)


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

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort()
	return divisors
b = make_divisors(m)
a = m // n
ans = 0
for i in b:
	if i <= a:
		ans = i
print(ans)


(N, M) = map(int, input().split())
d = []
for i in range(1, int(M ** 0.5) + 1):
	if M % i == 0:
		d.append(i)
		d.append(M // i)
d.sort()
for i in range(1, len(d) + 1):
	if d[-i] <= M // N:
		print(d[-i])
		exit()


import math
(n, m) = map(int, input().split())
X = 1
for i in range(1, 32000):
	if m % i == 0:
		if i * n <= m:
			X = max(X, i)
		if m // i * n <= m:
			X = max(X, m // i)
print(X)


(N, M) = map(int, input().split())
mx = 0
for i in range(1, int(M ** 0.5) + 1):
	if M % i == 0:
		if M // i >= N:
			mx = max(mx, i)
		if i >= N:
			mx = max(mx, M // i)
print(mx)


(N, M) = map(int, input().split())
gcd = M // N
while gcd * N != M:
	gcd = M // N
	N = 1 + (M - 1) // gcd
print(gcd)


(n, m) = map(int, input().split())
li = []
for i in range(int(m ** 0.5) + 1, 0, -1):
	if i == int(m ** 0.5) + 1 and (i - 1) ** 2 == m:
		continue
	if m % i == 0:
		li.append(i)
		li.append(m // i)
li.sort(reverse=True)
for i in li:
	if n <= m // i:
		print(i)
		break


(n, m) = map(int, input().split())
print(next((v for v in range(m // n, -1, -1) if m % v == 0)))


(N, M) = [int(str) for str in input().strip().split()]
for i in range(M // N, 0, -1):
	if M % i == 0:
		print(i)
		exit()
print(1)


(k, s) = list(map(int, input().split()))
p = s
factors = {}
while p > 1:
	f = False
	for i in range(2, int(p ** 0.5) + 1):
		if p % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			p //= i
			f = True
			break
	if not f:
		if p in factors:
			factors[p] += 1
		else:
			factors[p] = 1
		break
if len(factors) == 0:
	print(1)
else:
	primes = list(factors.keys())
	exp = [0] * len(primes)
	upper = s / k
	ans = 1
	while exp[0] <= factors[primes[0]]:
		num = 1
		for i in range(len(primes)):
			num *= pow(primes[i], exp[i])
		if num == upper:
			ans = num
			break
		elif num < upper:
			ans = max(ans, num)
		index = len(primes) - 1
		done = False
		while not done:
			exp[index] += 1
			if exp[index] > factors[primes[index]]:
				if index == 0:
					break
				else:
					exp[index] = 0
					index -= 1
			else:
				done = True
	print(ans)


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

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort(reverse=True)
	return divisors
numbers = make_divisors(m)
for i in range(len(numbers)):
	if numbers[i] <= m / n:
		print(numbers[i])
		break


import math

def main():
	(N, M) = [int(a) for a in input().split(' ')]
	divM = []
	for i in range(1, int(math.sqrt(M)) + 1):
		if M % i == 0:
			divM += [i, M // i]
	divM.sort()
	divM = list(filter(lambda m: m >= N, divM))
	print(M // divM[0])
main()


def divisor(x):
	from math import floor
	re = []
	_x = floor(x ** 0.5)
	for i in range(1, _x + 1):
		if x % i == 0:
			re.append(i)
			if x // i != i:
				re.append(x // i)
	re.sort()
	return re

def solve(N, M):
	div = divisor(M)
	div.sort()
	ans = 0
	for d in div:
		if M // d >= N:
			ans = d
	print(ans)

def __starting_point():
	(N, M) = list(map(int, input().split()))
	solve(N, M)
__starting_point()


(N, M) = map(int, input().split())
a = M // N
for i in range(a, 0, -1):
	if M % i == 0:
		print(i)
		exit()


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

def func(n, num):
	if num == 1:
		return 1
	else:
		for i in range(num // n, 0, -1):
			if num % i == 0:
				return i
print(func(n, m))


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()))
divisors = make_divisors(M)
ans = 0
for d in divisors:
	if N * d <= M:
		ans = d
print(ans)


import math
(N, M) = map(int, input().split())
for i in range(M // N + 1, 0, -1):
	if M % i == 0:
		if M // i >= N:
			print(i)
			exit()


(n, m) = map(int, input().split())
for i in range(m // n + 1)[::-1]:
	if m % i < 1:
		print(i)
		exit()


import math
(N, M) = map(int, input().split())
A = M // N
L = []
for i in range(1, int(math.sqrt(M)) + 1):
	if M % i == 0 and i <= A:
		L.append(i)
		if M // i <= A:
			L.append(M // i)
print(max(L))


(n, m) = map(int, input().split())
l = m // n

def x():
	for i in range(l + 1)[::-1]:
		if m % i == 0:
			return i
print(x())


(n, m) = map(int, input().split())
t = int(m / n)
while True:
	if m % t == 0:
		if t * n <= m:
			print(t)
			exit()
		else:
			t -= 1
	else:
		t -= 1


from bisect import bisect_right

def make_divisers(n):
	upper_result = []
	lower_result = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			lower_result.append(i)
			ii = n // i
			if ii != i:
				upper_result.append(ii)
	return lower_result + upper_result[::-1]

def main():
	(N, M) = map(int, input().split())
	divisers = make_divisers(M)
	idx = bisect_right(divisers, M / N) - 1
	print(divisers[idx])

def __starting_point():
	main()
__starting_point()


(n, m) = map(int, input().split())
l = []
for i in range(1, int(m ** 0.5) + 1):
	if m % i == 0:
		l.append(i)
		l.append(m // i)
r = [x for x in l if x <= m // n]
print(max(r))


(N, M) = map(int, input().split())
yakusuu = []
for i in range(1, int(M ** 0.5) + 1):
	if M % i == 0:
		yakusuu.append(i)
		yakusuu.append(M // i)
print(max([a for a in yakusuu if a * N <= M]))


(n, m) = map(int, input().split())
ans = 0
for i in range(1, round(m ** 0.5) + 2):
	if m % i == 0:
		k = m // i
		if k >= n:
			ans = max(i, ans)
		if i >= n:
			ans = max(k, ans)
print(ans)


(n, m) = map(int, input().split())
ans = 0
for i in range(1, int(m ** 0.5) + 1):
	if m % i > 0:
		continue
	a = i
	b = m // i
	if a * n <= m:
		ans = max(ans, a)
	if b * n <= m:
		ans = max(ans, b)
print(ans)


(n, m) = map(int, input().split())
l = []
for i in range(1, int(m ** (1 / 2)) + 1):
	if m % i == 0:
		l.append(i)
		l.append(m // i)
l.sort()
l = l[::-1]
for i in l:
	if m // n >= i:
		print(i)
		break


(n, m) = list(map(int, input().split()))
d = m // n + 1
for x in range(d)[::-1]:
	if m % x == 0:
		break
print(x)


(n, m) = map(int, input().split())
x = m // n

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]
y = make_divisors(m)
res = 1
for i in y:
	if i <= x:
		res = i
print(res)


from bisect import bisect_left, bisect

def enum_div(n):
	ir = int(n ** 0.5) + 1
	ret = []
	for i in range(1, ir):
		if n % i == 0:
			ret.append(i)
			if (i != 1) & (i * i != n):
				ret.append(n // i)
	return ret
(n, m) = list(map(int, input().split()))
div = enum_div(m) + [m]
div.sort(reverse=True)
rd = [0] * len(div)
for i in range(len(div)):
	rd[i] = m // div[i]
mm = bisect_left(rd, n)
print(div[mm])


(n, m) = list(map(int, input().split()))
yakusuu = []
for i in range(1, int(m ** 0.5) + 1):
	if m % i == 0:
		yakusuu.append(m // i)
		if m // i == i:
			continue
		yakusuu.append(i)
ans = 0
for y in yakusuu:
	if y < n:
		continue
	if m % y == 0:
		ans = max(ans, m // y)
print(ans)


(N, M) = list(map(int, input().split()))
ans = 1
for i in range(1, int(M ** 0.5) + 1):
	if M % i == 0:
		j = M // i
		if i >= N:
			ans = max(ans, j)
		if j >= N:
			ans = max(ans, i)
print(ans)


(n, m) = map(int, input().split())
K = m // n
ans = 0
i = 1
while i <= K:
	if m % i == 0:
		if m // i <= K:
			ans = m // i
			break
		ans = i
		K = min(m // n, m // i)
	i += 1
print(ans)


(n, m) = map(int, input().split())
ans = 1
for i in range(1, int(m ** 0.5) + 1):
	if m % i:
		continue
	if m // i >= n and i > ans:
		ans = i
	if i >= n and m // i >= ans:
		ans = m // i
print(ans)


(n, m) = map(int, input().split())
stack = []
for i in range(1, int(m ** 0.5) + 1):
	if m % i == 0:
		if i <= m // n:
			stack.append(i)
		if m // i <= m // n:
			stack.append(m // i)
print(max(stack))


def calc():
	(N, M) = map(int, input().split())
	for gcd in range(M // N, 0, -1):
		if M % gcd == 0:
			break
	return gcd
print(calc())


def prime(n):
	l = [[], []]
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			if i * i == n:
				l[0].append(i)
			else:
				l[0].append(i)
				l[1].append(n // i)
	return l[0] + l[1][::-1]
(n, m) = map(int, input().split())
x = 0
for i in prime(m):
	if i <= m // n:
		x = i
print(x)


(N, M) = map(int, input().split())

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]
l = make_divisors(M)
threshold = M / N
for (i, d) in enumerate(l):
	if threshold < d:
		print(l[i - 1])
		return
print(M)


(n, m) = map(int, input().split())
a = m // n
di = []
for i in range(1, min(a + 1, int(m ** 0.5) + 1)):
	if m % i == 0:
		di.append(i)
		if i != m // i and a >= m // i:
			di.append(m // i)
di.sort()
print(di[-1])


(N, M) = map(int, input().split())
divs = []
for i in range(1, int(M ** 0.5) + 1):
	if M % i == 0:
		divs.append(i)
		divs.append(M // i)
print(max([d for d in divs if d * N <= M]))


import math
(n, m) = map(int, input().split())
ans = list()
for i in range(1, int(math.sqrt(m)) + 1):
	if m % i == 0:
		ans.append(i)
		ans.append(m // i)
ans.sort(reverse=True)
for x in ans:
	if x <= m // n:
		print(x)
		break


import math
(n, m) = list(map(int, input().split()))
num = int(math.sqrt(m))
ans = 1
for i in range(1, num + 2):
	if m % i == 0 and i >= n:
		ans = max(ans, m // i)
		break
	if m % i == 0 and m // i >= n:
		ans = max(ans, i)
print(ans)


(N, M) = map(int, input().split())
L = []
ans = 0
for i in range(1, int(M ** (1 / 2) + 1)):
	if M % i == 0:
		if i >= N:
			ans = max(ans, M // i)
		if M // i >= N:
			ans = max(ans, i)
print(ans)


from math import sqrt

def divisors(n):
	divisors = []
	for i in range(1, int(sqrt(n)) + 1):
		(q, r) = divmod(n, i)
		if r == 0:
			divisors.append(i)
			if i != q:
				divisors.append(q)
	divisors.sort()
	return divisors
(n, m) = map(int, input().split())
ans = 1
for a in divisors(m)[1:]:
	if a * n <= m:
		ans = a
print(ans)


(N, M) = map(int, input().split())

def enum_div(N):
	ret = []
	for i in range(1, int(N ** 0.5) + 1):
		if N % i == 0:
			ret.append(i)
			if i ** 2 != N:
				ret.append(N // i)
		i += 1
	return ret
ans = 0
for i in enum_div(M):
	if i >= N:
		ans = max(ans, M // i)
print(int(ans))


import bisect
(N, M) = list(map(int, input().split()))
divd = []
i = 1
while i * i <= M:
	if M % i == 0:
		divd.append(i)
		if i != M // i:
			divd.append(M // i)
	i += 1
divd.sort()
k = bisect.bisect_left(divd, N)
print(M // divd[k])


import sys

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()))
i = 1
ans = 1
d_ls = make_divisors(M)
for i in d_ls:
	if i * N > M:
		break
	if (M - N * i) % i == 0:
		ans = i
	i += 1
print(ans)


(N, M) = map(int, input().split())
g = 1
for i in range(1, int(M ** (1 / 2)) + 1):
	if M % i == 0:
		if i >= N:
			g = M / i
			print(int(g))
			exit()
		elif i <= M / N:
			g = i
print(int(g))


(N, M) = map(int, input().split())

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
for i in reversed(range(1, M // N + 1)):
	if M % i == 0:
		print(i)
		break


(N, M) = map(int, input().split())

def enum_div(N):
	ret = []
	i = 1
	while True:
		if i ** 2 > N:
			break
		if N % i == 0:
			ret.append(i)
			if i ** 2 != N:
				ret.append(N / i)
		i += 1
	return ret
ans = 0
for i in enum_div(M):
	if i >= N:
		ans = max(ans, M / i)
print(int(ans))


def LI():
	return list(map(int, input().split()))
(N, M) = LI()
x = M // N
for i in range(x, 0, -1):
	if M % i != 0:
		continue
	ans = i
	break
print(ans)


from math import ceil, floor, factorial, gcd, sqrt, log2, cos, sin, tan, acos, asin, atan, degrees, radians, pi, inf
from itertools import accumulate, groupby, permutations, combinations, product, combinations_with_replacement
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
from operator import itemgetter
from heapq import heapify, heappop, heappush
from queue import Queue, LifoQueue, PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(MAP())

def divisor(n):
	i = 1
	table = []
	while i * i <= n:
		if n % i == 0:
			table.append(i)
			table.append(n // i)
		i += 1
	table = list(set(table))
	return table
(n, m) = MAP()
a = sorted(divisor(m))
print(m // a[bisect_left(a, n)])


def solve():
	(N, M) = map(int, input().split())
	for i in range(M // N, 0, -1):
		if not M % i:
			return str(i)
print(solve())


(n, m) = map(int, input().split())
l = [1]
k = m // n
if n == 1:
	print(m)
	exit()
for i in range(2, int(m ** 0.5) + 1):
	if m % i == 0:
		if i <= k:
			l.append(i)
		if m // i <= k:
			l.append(m // i)
print(max(l))


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

def solve():
	for i in range(m // n, 0, -1):
		if m % i == 0:
			if m // i >= n:
				print(i)
				break
solve()


(n, m) = list(map(int, input().split()))
ans = m // n
while m % ans != 0:
	ans -= 1
print(ans)


(N, M) = map(int, input().split())
ans = 1
i = 1
while i * i <= M:
	if M % i == 0 and M // N >= i:
		ans = max(ans, i)
		if M // i * N <= M:
			ans = max(ans, M // i)
	i += 1
print(ans)


from math import sqrt
(N, M) = map(int, input().split())
cand = []
for i in range(1, int(sqrt(M)) + 1):
	if M % i == 0:
		cand.append(i)
		u = M // i
		if u != i:
			cand.append(u)
cand.sort()
ans = 1
for j in cand:
	if N * j <= M:
		ans = max(ans, j)
print(ans)


(N, M) = list(map(int, input().split()))

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]
div_list = make_divisors(M)
div_list = div_list[::-1]
for div in div_list:
	if N * div <= M:
		print(div)
		return


(n, m) = list(map(int, input().split()))
a = m // n
for i in range(1, a + 1)[::-1]:
	if m % i == 0:
		break
print(i)


(N, M) = map(int, input().split())
a = M // N
x = 1
for i in range(1, a + 1):
	if M % i == 0:
		x = i
		if M // i > i and M // i <= a:
			x = M // i
			break
print(x)


(n, m) = map(int, input().split())
ans = 1
ps = []
for i in range(1, int(m ** (1 / 2)) + 1):
	if m % i:
		continue
	if n * i <= m:
		ans = max(i, ans)
	if n * (m // i) <= m:
		ans = max(ans, m // i)
print(ans)


def divisor(n):
	cd = []
	i = 1
	while i * i <= n:
		if n % i == 0:
			cd.append(i)
			if i != n // i:
				cd.append(n // i)
		i += 1
	return cd
(N, M) = map(int, input().split())
cd = divisor(M)
cd.sort(reverse=True)
for c in cd:
	if M // c >= N:
		print(c)
		break


[print(max([i for j in [[i, a[1] // i] for i in range(1, int(a[1] ** 0.5) + 1) if a[1] % i == 0] for i in j if a[1] // i >= a[0]])) for a in [list(map(int, input().split()))]]


def divisor(n):
	i = 1
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			if n // i not in res:
				res.append(n // i)
	res.sort(reverse=True)
	return res

def main():
	(n, m) = map(int, input().split())
	md = divisor(m)
	ans = 0
	for i in md:
		if i * n <= m:
			print(i)
			return

def __starting_point():
	main()
__starting_point()


from collections import defaultdict
(n, m) = list(map(int, input().split()))
ans = 0
i = 1
while i * i <= m:
	if m % i == 0:
		(a, b) = (i, m // i)
		if b >= n:
			ans = max(ans, a)
		if a >= n:
			ans = max(ans, b)
	i += 1
print(ans)


(N, M) = list(map(int, input().split()))

def primes(n):
	d = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			d.append(i)
			if n // i != i:
				d.append(n // i)
	d.sort()
	return d
d = primes(M)
for i in d[::-1]:
	if M // i >= N:
		ans = i
		break
print(ans)


(N, M) = map(int, input().split())
A = []
for i in range(1, M + 1):
	if i * i > M:
		break
	if M % i == 0:
		A.append(i)
		A.append(M // i)
A.sort()
for a in A:
	if a >= N:
		print(M // a)
		break


(n, m) = map(int, input().split())
p = 1
for i in range(1, int(m ** 0.5) + 1):
	if m % i == 0:
		if m // i >= n:
			if i >= n:
				p = max(i, m // i, p)
			else:
				p = max(p, i)
print(p)


(N, M) = map(int, input().split())
a = 1
for i in range(1, 4 * 10000):
	if M % i:
		continue
	if M // i >= N and i > a:
		a = i
	if i >= N and M // i > a:
		a = M // i
print(a)


def run():
	(N, M) = (int(x) for x in input().split())
	i = 2
	result = 1
	for i in range(M // N, 0, -1):
		if M % i == 0:
			print(i)
			break
run()


(N, M) = map(int, input().split())
output = 1
for i in range(M // N, 0, -1):
	if M % i == 0 and output < i:
		output = i
		break
print(output)


def main():
	import sys

	def input():
		return sys.stdin.readline().rstrip()

	def divisor(m):
		arr = [1, m]
		i = 2
		while i * i <= m:
			if m % i == 0:
				arr.append(i)
				if m // i != i:
					arr.append(m // i)
			i += 1
		arr.sort()
		return arr
	(n, m) = map(int, input().split())
	a = divisor(m)
	for x in a:
		if x >= n:
			print(m // x)
			return

def __starting_point():
	main()
__starting_point()


(n, m) = list(map(int, input().split()))
i = n
while i * i <= m:
	if m % i == 0:
		print(m // i)
		exit()
	i += 1
j = m // i
while j > 0:
	if m % j == 0:
		print(j)
		exit()
	j -= 1


(N, M) = map(int, input().split())

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
ans = 1
for i in make_divisors(M):
	work1 = i * N
	work2 = M - work1
	if work2 >= 0 and work2 % i == 0:
		ans = max(i, ans)
print(ans)


(n, m) = map(int, input().split())
L = []
x = m / n
for i in range(1, min(int(x) + 1, int(m ** 0.5) + 1)):
	if m % i == 0:
		if i <= x:
			L.append(i)
		if m // i <= x:
			L.append(m // i)
print(max(L))


(n, m) = [int(_) for _ in input().split(' ')]
ds = [i for i in range(1, int(m ** 0.5) + 1) if m % i == 0]
ds.extend([m // i for i in ds])
print(max([i for i in ds if i <= m // n]))


(N, M) = map(int, input().split())
d = []
for i in range(1, int(M ** 0.5) + 1):
	if M % i == 0:
		d.append(i)
		if i ** 2 != M:
			d.append(M // i)
d.sort(reverse=True)
for i in d:
	if i * N <= M:
		print(i)
		exit()


def enum_divisors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			if i != n // i:
				res.append(n // i)
	return res
(N, M) = list(map(int, input().split()))
divs = sorted(enum_divisors(M), reverse=True)
ans = max((d for d in divs if M // d >= N))
print(ans)


(N, M) = list(map(int, input().split()))
import math
G = []
for i in range(1, int(math.sqrt(M)) + 2 + 1):
	if M % i == 0:
		cd = M // i
		G.append(cd)
		G.append(i)
G.sort(reverse=True)
for g in G:
	n = M // g
	if n >= N:
		print(g)
		return


(N, M) = [int(i) for i in input().split()]
l = []
for i in range(1, int(M ** 0.5 + 2)):
	if M % i == 0:
		if M / i >= N:
			l.append(i)
		if i >= N:
			l.append(M / i)
print(int(max(l)))


(N, M) = map(int, input().split())
base = M // N
li = []
for i in range(1, int(pow(M, 1 / 2)) + 1):
	if i <= base and M % i == 0:
		li.append(i)
	if M % i == 0 and M // i <= base:
		li.append(M // i)
print(max(li))


from sys import stdin
nii = lambda : map(int, stdin.readline().split())
lnii = lambda : list(map(int, stdin.readline().split()))
(n, m) = nii()

def divisore(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort(reverse=True)
	return divisors
d = divisore(m)
for x in d:
	zan = m - x * n
	if zan >= 0 and zan % x == 0:
		print(x)
		return


(N, M) = map(int, input().split())
m = 1
ds = set()
while m * m <= M:
	if M % m == 0:
		ds.add(m)
		ds.add(M // m)
	m += 1
ans = 1
for d in ds:
	if d * N > M:
		continue
	ans = max(ans, d)
print(ans)


import sys

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) = map(int, input().split())
c = M // N
L = make_divisors(M)
L = list(reversed(L))
for i in range(len(L)):
	if L[i] <= c:
		print(L[i])
		return


(N, M) = list(map(int, input().split()))
a = M // N
for i in range(a, 0, -1):
	if M % i == 0:
		print(i)
		break


def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
(n, m) = map(int, input().split())
h = m // n
ans = 0
for d in make_divisors(m):
	if d <= h:
		ans = max(ans, d)
print(ans)


import math
(n, m) = map(int, input().split())
ans = 1
for i in range(1, math.ceil(math.sqrt(m))):
	if m % i == 0:
		if m >= n * i:
			ans = max(ans, i)
		j = m // i
		if m >= n * j:
			ans = max(ans, j)
print(ans)


import sys
input = sys.stdin.readline

def read():
	(N, M) = list(map(int, input().strip().split()))
	return (N, M)

def divisor(n):
	divisors = []
	i = 1
	while i * i <= n:
		if n % i == 0:
			divisors.append(i)
			if i * i != n:
				divisors.append(n // i)
		i += 1
	return list(sorted(divisors))

def solve(N, M):
	D = divisor(M)
	ans = 1
	for p in D:
		n = M // p
		if n >= N:
			ans = max(ans, p)
	return ans

def __starting_point():
	inputs = read()
	outputs = solve(*inputs)
	if outputs is not None:
		print('%s' % str(outputs))
__starting_point()


(n, m) = map(int, input().split())
k = m // n
ans = 1
i = 1
while i ** 2 <= m:
	if m % i == 0:
		j = m // i
		if j <= k:
			print(j)
			exit()
		if i <= k:
			ans = max(ans, i)
	i += 1
print(ans)


(n, m) = map(int, input().split())
temp = m // n
(i, ans) = (1, 1)
while i * i <= m:
	if m % i == 0:
		if ans < i <= temp:
			ans = i
		if ans < m // i <= temp:
			ans = m // i
	i += 1
print(ans)


(n, m) = list(map(int, input().split()))
ls = []
for i in range(1, int(m ** (1 / 2)) + 1):
	if m % i == 0:
		ls.append(i)
		ls.append(m // i)
ls = sorted(list(set(ls)), reverse=True)
for j in ls:
	if j * n <= m:
		print(j)
		break


(N, M) = map(int, input().split())

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]
A = make_divisors(M)
for i in range(len(A)):
	if A[i] >= N:
		print(A[-1 - i])
		return


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

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]
l = make_divisors(m)
l.reverse()
for x in l:
	if m // x >= n:
		print(x)
		break


(N, M) = map(int, input().split())
D = []
for i in range(1, int(M ** 0.5 + 1)):
	if M % i == 0:
		D.append(i)
		D.append(M // i)
D.sort()
for j in D:
	if j >= N:
		print(M // j)
		exit()


(n, m) = map(int, input().split())
i = 1
x = []
while i * i <= m:
	if m % i == 0:
		x.append(i)
		x.append(m // i)
	i += 1
x.sort()
for xi in x:
	if xi >= n:
		print(m // xi)
		break


(N, M) = list(map(int, input().split(' ')))

def solv(N, M):
	d = M // N
	for i in range(d + 1)[::-1]:
		if M % i == 0:
			return i
print(solv(N, M))


(n, m) = map(int, input().split())
ans = 0
import math
for i in range(1, int(math.sqrt(m)) + 1):
	if m % i != 0:
		continue
	i2 = m // i
	if i * n <= m:
		ans = max(ans, i)
	if i2 * n <= m:
		ans = max(ans, i2)
print(ans)


(n, m) = map(int, input().split())
an = m // n
while an * n != m:
	an = m // n
	n = 1 + (m - 1) // an
print(an)


(N, M) = list(map(int, input().split()))
(s, r) = divmod(M, N)
ans = 1
for i in range(s, 0, -1):
	if M % i == 0:
		print(i)
		break


from math import sqrt
from math import floor
(n, m) = map(int, input().split())
d = m // n
ans = 1
for i in range(1, floor(sqrt(m)) + 1):
	if m % i == 0:
		x = m // i
		if i <= d:
			ans = max(ans, i)
		if x <= d:
			ans = max(ans, x)
print(ans)


from math import sqrt
(n, m) = list(map(int, input().split()))
ans = 1
for i in range(1, int(sqrt(m) + 2)):
	if m % i == 0:
		if i <= m / n:
			ans = max(ans, i)
		if m // i <= m / n:
			ans = max(ans, m // i)
print(ans)


(N, M) = map(int, input().split())

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 sorted(lower_divisors + upper_divisors[::-1], reverse=True)
divisors = make_divisors(M)
for d in divisors:
	tmp = M // d
	if tmp >= N:
		print(d)
		break


(N, M) = map(int, input().split())
L = []
for i in range(1, int(M ** 0.5) + 1):
	if M % i == 0:
		L.append(i)
		L.append(int(M / i))
L1 = [i for i in L if M / i >= N]
print(max(L1))


def resolve():

	def make_divisors(n):
		divisors = []
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				divisors.append(i)
				if i != n // i:
					divisors.append(n // i)
		divisors.sort(reverse=True)
		return divisors
	(N, M) = list(map(int, input().split()))
	div = make_divisors(M)
	for d in div:
		if d <= M // N:
			print(d)
			break

def __starting_point():
	resolve()
__starting_point()


(N, M) = map(int, input().split())
i = 1
lis = []
while M // i >= N and i <= M ** 0.5:
	if M % i == 0:
		lis.append(i)
	i += 1
for l in lis[::-1]:
	ans = M // l
	if M // ans >= N:
		lis.append(ans)
print(lis[-1])


import sys
import math
(N, M) = map(int, sys.stdin.readline().split())
ans = 0
for i in range(1, int(M ** 0.5) + 1):
	if M % i == 0:
		j = M // i
		r1 = j // N
		r2 = j % N
		ans = max(ans, min(r1, math.gcd(r1, r2)) * i)
		r1 = i // N
		r2 = i % N
		ans = max(ans, min(r1, math.gcd(r1, r2)) * j)
print(ans)


(n, m) = map(int, input().split())
max_cnd = m // n
for i in range(max_cnd):
	if m % (max_cnd - i) == 0:
		print(max_cnd - i)
		exit()


(n, m) = map(int, input().split())
a = 0
for i in range(1, int(m ** 0.5) + 1):
	if m % i == 0 and m // i >= n:
		a = max(a, i)
	if m % i == 0 and i >= n:
		a = max(a, m // i)
print(a)


from itertools import *
(n, m) = map(int, input().split())
M = m
a = [1]
for i in range(2, int(m ** 0.5) + 1):
	while m % i == 0:
		m //= i
		a += [i]
if m != 1:
	a += [m]
ans = 1
for i in range(len(a)):
	for b in combinations_with_replacement(set(a), i):
		c = 1
		for j in b:
			c *= j
		if c >= n and M % c == 0:
			ans = max(ans, M // c)
print(ans)


(n, m) = list(map(int, input().split()))
ans = 0
for i in range(1, int(m ** 0.5) + 1):
	if m % i == 0 and i <= m / n:
		if m // i <= m / n:
			ans = m // i
			break
		else:
			ans = i
print(ans)


from math import sqrt

def f(x):
	divisors = [[], []]
	for i in range(1, int(sqrt(x)) + 1):
		if x % i == 0:
			divisors[0].append(i)
			if i * i != x:
				divisors[1].append(x // i)
	return divisors[0] + divisors[1][::-1]
(n, m) = map(int, input().split())
for i in f(m):
	if n <= i:
		print(m // i)
		return


(n, m) = list(map(int, input().split()))
i = 1
ans = 0
while i * i <= m:
	if m % i == 0:
		if n <= m / i:
			ans = max(ans, i)
		if n <= i:
			ans = max(ans, m // i)
	i += 1
print(ans)


(n, m) = map(int, input().split())
max_num = int(m / n)
ans = -1
for i in reversed(range(max_num + 1)):
	if m % i == 0:
		ans = i
		break
print(ans)


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


(n, m) = map(int, input().split())
g = m // n
while 1:
	if m % g == 0:
		break
	g -= 1
print(g)


(n, m) = map(int, input().split())
p = m // n
while m % p != 0:
	p -= 1
print(p)


(x, y) = map(int, input().split())
a = 1
k = pow(y, 0.5)
for i in range(1, int(k) + 1):
	if y % i == 0:
		if i * x <= y:
			a = max(a, i)
		if y // i * x <= y:
			a = max(a, y // i)
print(a)


(N, M) = map(int, input().split())
ls = []
for i in range(1, M + 1):
	if M % i == 0:
		j = M // i
		if i <= M // N:
			ls += [i]
		if j <= M // N:
			ls += [j]
	if M ** 0.5 < i:
		break
print(max(ls))


import copy
import random
import bisect
import fractions
import math
import sys
import collections
from decimal import Decimal
mod = 10 ** 9 + 7
sys.setrecursionlimit(mod)
d = collections.deque()

def LI():
	return list(map(int, sys.stdin.readline().split()))
(N, M) = LI()

def primes(n):
	cnt = collections.defaultdict(int)
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			while n % i == 0:
				cnt[i] += 1
				n //= i
	if n != 1:
		cnt[n] += 1
	return cnt

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]
divs = make_divisors(M)
ans = -1
for (i, divisior) in enumerate(divs):
	if divisior > M // N:
		break
	else:
		ans = divisior
print(ans)


import sys
input = sys.stdin.readline

def calc_divisors(n):
	divisors_a = []
	divisors_b = []
	for d in range(1, int(n ** 0.5) + 1):
		if n % d == 0:
			divisors_a.append(d)
			if n // d != d:
				divisors_b.append(n // d)
	divisors = divisors_a + divisors_b[::-1]
	return divisors

def main():
	(N, M) = list(map(int, input().split()))
	divisors = calc_divisors(M)
	ans = 0
	for divisor in divisors:
		if M // divisor >= N:
			ans = max(ans, divisor)
	print(ans)

def __starting_point():
	main()
__starting_point()


import math
(N, M) = map(int, input().split())
l = []
for i in range(1, int(math.sqrt(M)) + 1):
	if M % i == 0:
		l.append(i)
		if i != M // i:
			l.append(M // i)
l.sort(reverse=True)
for n in l:
	if n * N <= M:
		ans = n
		break
print(ans)


(n, m) = list(map(int, input().split(' ')))
ds = [x for x in range(1, int(m ** 0.5) + 1) if m % x == 0]
ds = ds + [m // x for x in ds]
ds = [x for x in ds if x <= m // n]
print(max(ds))


(n, k) = map(int, input().split())
m = 1
for i in range(k // n + 1)[::-1]:
	if k % i == 0 and k // i >= n:
		m = i
		break
print(m)


import math
(n, m) = list(map(int, input().split()))
if n == 1:
	print(m)
	return
a = []
b = []
for i in range(1, math.ceil(math.sqrt(m))):
	if m % n == 0:
		print(m // n)
		return
	if m % i == 0:
		b.append(i)
		b.append(m // i)
for i in range(len(b)):
	if b[i] * n <= m:
		a.append(b[i])
if len(b) == 2:
	print(1)
else:
	print(max(a))