CodeEff/ECCO huggingface dataset:
# Original solution
N,M = list(map(int,input().split()))

if M % N == 0:    print((M//N))
else:
    for i in range(N,M//2+1):
        if M % i == 0:
            print((M//i))
            break
    else:
        print((1))


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

if M % N == 0:    print((M//N))
elif M//N > 100000:
    for i in range(N,M//2+1):
        if M % i == 0:
            print((M//i))
            break
    else:
        print((1))
else:
    m = M//N
    for i in range(2,m)[::-1]:
        if M % i == 0:
            print(i)
            break
    else:
        print((1))
# Original solution
N, M = list(map(int, input().split()))
x = M//N
max = 1
for i in range(1, x+1):
    mod = M - (N-1)*i
    if mod%i == 0:
        if max < i:
            max = i
print(max)

# Optimized solution
N, M = list(map(int, input().split()))
x = M//N
max = 1
for i in range(x, 0, -1):
    mod = M - (N-1)*i
    if mod%i == 0:
        max = i
        break
print(max)
# Original solution
N,M = list(map(int,input().split()))
div = 1
for i in range(2,M//N+1):
    if M%i==0:
        div = i
print(div)


# Optimized solution
N,M = list(map(int,input().split()))
div = 1
for i in range(2,M//N+1)[::-1]:
    if M%i==0:
        div = i
        break
print(div)
# Original solution
n, m = list(map(int, input().split()))

lstDiv = []
k = 1
while k * k <= m:
    div, r = divmod(m, k)
    if r == 0:
        lstDiv.append(k)
        lstDiv.append(div)
    k += 1

lstDiv = sorted(lstDiv, reverse=True)

for div in lstDiv:
    if div * n <= m:
        print(div)
        break

# Optimized solution
from bisect import bisect_left

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

st = set()
i = 1
while i * i <= m:
    if m % i == 0:
        st.add(i)
        st.add(m // i)
    i += 1

divs = tuple(sorted(st))
i = bisect_left(divs, n)
print((m // divs[i]))
# Original solution
from bisect import bisect_left

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

st = set()
i = 1
while i * i <= m:
    if m % i == 0:
        st.add(i)
        st.add(m // i)
    i += 1

divs = tuple(sorted(st))
i = bisect_left(divs, n)
print((m // divs[i]))


# Optimized solution
def main():
    N, M = list(map(int, input().split()))

    st = {1, M}
    d = 2
    while d * d <= M:
        if M % d == 0:
            st.add(d)
            st.add(M // d)
        d += 1

    ans = 1
    for d in st:
        if d >= N:
            e = M // d
            ans = max(ans, e)
    print(ans)


if __name__ == '__main__':
    main()
# Original solution
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(eval(input()))

def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print((k.join(list(map(str, lst)))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    N, M = MI()

    ans = 1
    for i in range(1, int(pow(M, 0.5))+1):
        if M % i: continue
        j = M // i

        if i * N <= M: ans = max(ans, i)
        if j * N <= M: ans = max(ans, j)
    print(ans)




if __name__ == '__main__':
    solve()


# Optimized solution
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SMI(): return input().split()
def SLI(): return list(eval(input()))
def printlist(lst, k=' '): print((k.join(list(map(str, lst)))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N, M = MI()

    ans = 1
    for i in range(1, int(pow(M, 0.5))+1):
        if M % i: continue
        if N * i <= M: ans = max(ans, i)
        if N * (M // i) <= M: ans = max(ans, M//i)
    print(ans)

if __name__ == '__main__':
    solve()
# Original solution
from math import sqrt

N, M = list(map(int, input().split()))
ans = max(M // i if M // i <= M / N else i  for i in range(1, int(sqrt(M)) + 1) if M % i == 0 and i <= M / N)
print(ans)

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

# Mの約数dのうち、 dN <= M を満たす最大のdが解
ans = max(
    (
        M // d if (M // d) * N <= M else
        d if d * N <= M else
        1
    )
    for d in range(1, int(M**0.5) + 10)
    if M % d == 0
)

print(ans)
# Original solution
N,M = list(map(int,input().split()))
for gcd in range(M // N,0,-1):
 if M % gcd == 0:
  print(gcd)
  break

# Optimized solution
def calc():
 N,M = list(map(int,input().split()))
 for gcd in range(M // N,0,-1):
  if M % gcd == 0:
   break
 return(gcd)
print((calc()))
# Original solution
def calc():
 N,M = list(map(int,input().split()))
 gcd = M // N
 while gcd > 0:
  tmp = M - gcd
  if tmp % gcd == 0:
   break
  gcd = gcd - 1
 return(gcd)
print((calc()))

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

def solve():
	i = 0
	while True:
		if M%(N+i+1) == 0:
			print((int(M/(N+i+1))))
			break
		i += 1

if M%N == 0:
	print(d)
else:
	solve()

# Optimized solution
N, M = list(map(int,input().split()))
 
d = int(M/N)

def solve():
    ans = 1
    for i in range(M//N+1, 0, -1):
        if M % i == 0:
            if (M // i) >= N:
                print(i)
                break
	# i = 0
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

if M%N == 0:
	print(d)
else:
	solve()
# Original solution
N, M = list(map(int,input().split()))
 
d = int(M/N)

def solve():
    # ans = 1
    # for i in range(M//N+1, 0, -1):
    #     if M % i == 0:
    #         if (M // i) >= N:
    #             print(i)
    #             break
    for i in range(d):
    	if M%(d-i) == 0:
    		print((d-i))
    		break

	# i = 0
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

if M%N == 0:
	print(d)
else:
	solve()

# Optimized solution
N, M = list(map(int,input().split()))
 
d = int(M/N)

def solve():
    # ans = 1
    # for i in range(M//N+1, 0, -1):
    #     if M % i == 0:
    #         if (M // i) >= N:
    #             print(i)
    #             break
    for i in range(d+1,0,-1):
    	if M%i == 0:
    		print(i)
    		break

	# i = 0
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

if M%N == 0:
	print(d)
else:
	solve()
# Original solution
def divisor(n):
    i = 1
    res = []
    while i*i <= n:
        if n%i == 0:
            res.append(i)
            if n//i not in res:
                res.append(n//i)
        i += 1
    res.sort()
    return res

def main():
    n, m = list(map(int, input().split()))
    md = divisor(m)
    ans = 0
    for i in md:
        if (m - n*i)%i == 0 and (m - n*i) >= 0:
            ans = i
        else:
            break
    print(ans)

if __name__ == '__main__':
    main()

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

def main():
    n, m = list(map(int, input().split()))
    md = divisor(m)
    ans = 0
    for i in md:
        if (m - n*i)%i == 0 and (m - n*i) >= 0:
            ans = i
        else:
            break
    print(ans)

if __name__ == '__main__':
    main()
# Original solution
def divisor(n):
    i = 1
    res = []
    for i in range(1, int(n**.5) + 1):
        if n%i == 0:
            res.append(i)
            if n//i not in res:
                res.append(n//i)
    res.sort()
    return res

def main():
    n, m = list(map(int, input().split()))
    md = divisor(m)
    ans = 0
    for i in md:
        if (m - n*i)%i == 0 and (m - n*i) >= 0:
            ans = i
        else:
            break
    print(ans)

if __name__ == '__main__':
    main()

# Optimized solution
def divisor(n):
    i = 1
    res = []
    for i in range(1, int(n**.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 = list(map(int, input().split()))
    md = divisor(m)
    ans = 0
    for i in md:
        if i*n <= m:
            print(i)
            exit()

if __name__ == '__main__':
    main()
# Original solution
N, M = list(map(int, input().split()))
print((max(d for d in range(1, M // N + 1) if M % d == 0)))


# Optimized solution
N, M = list(map(int, input().split()))
print((next(d for d in reversed(list(range(M // N + 1))) if M % d == 0)))
# Original solution
def divisors(N):
    res = []
    i = 1
    while i * i <= N:
        q, r = divmod(N, i)
        if r == 0:
            res.append(i)
            if i != q:
                res.append(q)
        i += 1
    res.sort()
    return res

N, M = list(map(int, input().split()))
print((max(d for d in divisors(M) if d * N <= M)))


# Optimized solution
def divisors(N):
    res = []
    i = 1
    while i * i <= N:
        q, r = N // i, N % i
        if r == 0:
            res.append(i)
            if i != q:
                res.append(q)
        i += 1
    res.sort()
    return res

N, M = list(map(int, input().split()))
print((max(d for d in divisors(M) if d * N <= M)))
# Original solution
def divisors(N):
    res = []
    i = 1
    while i * i <= N:
        q, r = N // i, N % i
        if r == 0:
            res.append(i)
            if i != q:
                res.append(q)
        i += 1
    res.sort()
    return res

N, M = list(map(int, input().split()))
print((max(d for d in divisors(M) if d * N <= M)))


# Optimized solution
def divisors(N):
    res = []
    i = 1
    while i * i <= N:
        if N % i == 0:
            res.append(i)
            q = N // i
            if i != q:
                res.append(q)
        i += 1
    res.sort()
    return res

N, M = list(map(int, input().split()))
print((max(d for d in divisors(M) if d * N <= M)))
# Original solution
def divisors(N):
    res = []
    i = 1
    while i * i <= N:
        if N % i == 0:
            res.append(i)
            if i * i != N:
                res.append(N // i)
        i += 1
    res.sort()
    return res

N, M = list(map(int, input().split()))
print((max(d for d in divisors(M) if d * N <= M)))


# Optimized solution
def divisors(N):
    res = []
    i = 1
    while i * i < N:
        if N % i == 0:
            res.append(i)
            res.append(N // i)
        i += 1
    if i * i == N and N % i == 0:
        res.append(i)
    res.sort()
    return res

N, M = list(map(int, input().split()))
print((max(d for d in divisors(M) if d * N <= M)))
# Original solution
def divisors(N):
    res = []
    i = 1
    while i * i < N:
        if N % i == 0:
            res += [i, N // i]
        i += 1
    if N % i == 0:
        res.append(i)
    res.sort()
    return res

N, M = list(map(int, input().split()))
print((max(d for d in divisors(M) if d * N <= M)))


# Optimized solution
def divisors(N):
    res = []
    i = 1
    for i in range(1, int(N ** 0.5)):
        if N % i == 0:
            res += [i, N // i]
    if N % i == 0:
        res.append(i)
    res.sort()
    return res

N, M = list(map(int, input().split()))
print((max(d for d in divisors(M) if d * N <= M)))
# Original solution
def divisors(N):
    i = 1
    U = int(N ** 0.5)
    res = []
    for i in range(1, U):
        if N % i == 0:
            res += [i, N // i]
    if N % i == 0:
        res.append(i)
    res.sort()
    return res

N, M = list(map(int, input().split()))
print((max(d for d in divisors(M) if d * N <= M)))


# Optimized solution
def divisors(N):
    U = int(N ** 0.5)
    res = []
    for i in range(1, U):
        if N % i == 0:
            res += [i, N // i]
    if N % U == 0:
        res.append(U)
    res.sort()
    return res

N, M = list(map(int, input().split()))
print((max(d for d in divisors(M) if d * N <= M)))
# Original solution
n,m = list(map(int,input().split(" ")))

for i in range(0,m-n+1):
    if m%(n+i) == 0:
        print((int(m/(n+i))))
        break

# Optimized solution
n,m = list(map(int,input().split(" ")))

i_m = m
import math
root_m = int(math.sqrt(m))

m_s = []
for i in range(2,root_m+1):
    while m%i == 0:
        m_s.append(i)
        m = int(m/i)
        if m == 1:
            break
    if m ==1:
        break

if m_s == []:
    if n == 1:
        print(i_m)
    else:
        print((1))

else:
    for i in range(0,i_m-n+1):
        if i_m%(n+i) == 0:
            print((int(i_m/(n+i))))
            break
# Original solution
N,T  = list(map(int,input().split()))
d = int(T / N)
if T % N == 0:
    print (d)


else:
    for i in range(d+1,0,-1):    
        if T % i ==0:
            print(i)
            break
   

# Optimized solution
N,T  = list(map(int,input().split()))
d = int(T / N)
def ans():
    for i in range(d+1,0,-1):    
            if T % i ==0:
                print(i)
                break
if T % N == 0:
    print (d)
else:
    ans()
# Original solution
import math

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

for i in range(2,int(math.sqrt(m)+1)):
    if m % i == 0:
        flag = True
        break

if flag == True:
    for i in range(int(m/n),0,-1):
        if m % i == 0:
            print(i)
            break
else:
    print((1))

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

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

yakusuu(n,m)
# Original solution
N, M = list(map(int, input().split()))
tmp=0

if N==1:
  print(M)
  tmp=1
else:
  for i in range(M-N):
    k = i + N
    if M % k == 0:
      print((int(M/k)))
      tmp=1
      break

if tmp==0:
  print((1))

# Optimized solution
N, M = list(map(int, input().split()))
tmp=0

if N==1:
  print(M)
  tmp=1
else:
  for i in range(int(M**0.8)+1):
    k = i + N
    if M % k == 0:
      print((int(M/k)))
      tmp=1
      break

if tmp==0:
  print((1))
# Original solution
N, M = list(map(int, input().split()))

D = []
d = 1
while M >= N * d:
	if M % d == 0:
		D.append(d)
	d += 1

print((max(D)))

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

def divisible(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

div = divisible(M)

div = [d for d in div if d <= M / N]

print((max(div)))
# Original solution
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)

# Optimized solution
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)
# Original solution
N,M = list(map(int,input().strip().split()))
ans = 1
i = 0

while M//2 >= N+i:
    if M%(N+i) == 0:
        ans = M//(N+i)
        break
    else:
        i += 1

print(ans)

# Optimized solution
import math

N,M = list(map(int,input().strip().split()))
ans = 1
i = 0

def is_prime(num):
    if num < 2:
        return False
    if num == 2 or num == 3 or num == 5:
        return True
    if num % 2 == 0 or num % 3 == 0 or num % 5 == 0:
        return False

    prime = 7
    step = 4
    num_sqrt = math.sqrt(num)
    while prime <= num_sqrt:
        if num % prime == 0:
            return False
        prime += step
        step = 6 - step

    return True

if is_prime(M) == False:
    while M//2 >= N+i:
        if M%(N+i) == 0:
            ans = M//(N+i)
            break
        else:
            i += 1

print(ans)
# Original solution
INFTY = 10**5
P = [1 for _ in range(INFTY)]
P[0]=0
P[1]=0
for i in range(2,int(INFTY**0.5)+1):
    for j in range(i*i,INFTY,i):
        P[j] = 0
Q = []
for i in range(INFTY):
    if P[i]==1:
        Q.append(i)
N,M = list(map(int,input().split()))
y = 1
for q in Q:
    if M%q==0:
        y = 0
        break
if N==1:
    x = M
elif y==1:
    x = 1
else:
    b = M//N
    for i in range(b,0,-1):
        if M%i==0:
            x = i
            break
print(x)

# Optimized solution
N,M = list(map(int,input().split()))
k = 1
for i in range(1,int(M**0.5)+1):
    if M%i==0:
        a = i
        b = M//i
        k1 = 1
        k2 = 1
        if b>=N:
            k1 = a
        if a>=N:
            k2 = b
        k = max(k,k1,k2)
print(k)
# Original solution
N,M = list(map(int,input().split()))
if N==1:
    nmax=M
else:
    nmax = 1
    for i in range(2,int(M**0.5)+1):
        if M%i==0 and M//i>=N:
            nmax = max(nmax,i)
        if M%i==0 and i>=N:
            nmax = max(nmax,M//i)
print(nmax)

# Optimized solution
N,M = list(map(int,input().split()))
amax = 1
for i in range(1,int(M**0.5)+1):
    if M%i==0:
        a = i
        b = M//i
        if b>=N:
            amax = max(amax,a)
        a,b = b,a
        if b>=N:
            amax = max(amax,a)
print(amax)
# Original solution
N,M = list(map(int,input().split()))
amax = 1
for i in range(1,int(M**0.5)+1):
    if M%i==0:
        a = i
        b = M//i
        if b>=N:
            amax = max(amax,a)
        a,b = b,a
        if b>=N:
            amax = max(amax,a)
print(amax)

# Optimized solution
N,M = list(map(int,input().split()))
g = 0
for i in range(1,int(M**0.5)+1):
    if M%i==0:
        a = i
        b = M//i
        if a>=N:
            g = max(g,b)
        if b>=N:
            g = max(g,a)
print(g)
# Original solution
N, M = list(map(int, input().split()))

re = 1
for i in range(1, M // N + 1):
    if M % i == 0:
        a = M // i
        if a >= N:
            re = i
        else:
            break
print(re)  

# Optimized solution
def factorize(n):
    fct = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop() 
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]

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

if M == 1:
    print((1))
else:
    re = 1
    fa = factorize(M)
    div_list = divisorize(fa)

    for i in range(len(div_list)):
        num = 1
        for j in range(len(div_list[-1 - i])):
            l = div_list[-1-i][j]
            num *= l[0] ** l[1]
        d = M // num 
        if d >= N and num > re:
            re = num
    print(re)
# Original solution
n, m = list(map(int, input().split()))

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

solve()


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

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

solve()
# Original solution
n, m = list(map(int, input().split()))
for i in range(m//n, 0, -1):
  if m%i==0:
    break
print(i)

# Optimized solution
def solve():
  n, m = list(map(int, input().split()))
  for i in range(m//n, 0, -1):
    if m%i==0:
      break
  print(i)

if __name__=='__main__':
  solve()
# Original solution
n,m = list(map(int,input().split()))
ans = 0
tmp = 1
while True:
    num = m - tmp*(n-1)
    if num < tmp:
        break
    elif num % tmp == 0:
        ans = tmp
    tmp += 1
print(ans)

# Optimized solution
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)
    return divisors
ans = 1
lst = make_divisors(m)
lst.sort()
for d in lst:
    if m>=d*n:
        ans = d
print(ans)
# Original solution
N, M = list(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]))

# Optimized solution
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 = list(map(int, input().split()))
cd = divisor(M)
cd.sort(reverse=True)
for c in cd:
  if M//c>=N:
    print(c)
    break
# Original solution
n,m = list(map(int,input().split()))

ans = 1
for i in range(1,m//n+1):
    rest = m - (i * (n - 1))
    if rest % i == 0:
        ans = i

print(ans)

# Optimized solution
import sys
n,m = list(map(int,input().split()))

ans = 1
for i in range(m//n,0,-1):
    rest = m - (i * (n - 1))
    if rest % i == 0:
        print(i)
        sys.exit()
# Original solution
n,m=list(map(int,input().split()))
for i in range(m//n+1)[::-1]:
  if m%i==0:
    print(i)
    exit()


# Optimized solution
def f():
  n,m=list(map(int,input().split()))
  for i in range(m//n+1)[::-1]:
    if m%i==0:return i
print((f()))
# Original solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


n, m = list(map(int, readline().split()))
if is_prime(m) and n != 1:
    print((1))
    exit()
for i in range(m // n, 0, -1):
    if m % i == 0:
        print(i)
        exit()


# Optimized solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


n, m = list(map(int, readline().split()))
if is_prime(m):
    if n == 1:
        print(m)
    else:
        print((1))
    exit()
for i in range(m // n, 0, -1):
    if m % i == 0:
        print(i)
        exit()