Problem:
 Score : 400 points    Problem Statement 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 1 3 14      Sample Output 1 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.       Sample Input 2 10 123      Sample Output 2 3       Sample Input 3 100000 1000000000      Sample Output 3 10000

Solution (Python):
n,m = map(int,input().split())
factor = []
for i in range(1,int(m**0.5)+2):
    if m%i == 0:
        factor.append(i)
        factor.append(m//i)
factor.sort()
factor.reverse()
for i in range(len(factor)):
    if m%factor[i] == 0:
        if m//factor[i] >= n:
            print(factor[i])
            break

Solution (Python):
N, M = [int(x) for x in input().strip().split(' ')]

if N >= 1000:
    for i in range(M//N):
        n = (M//N)-i
        if M % n == 0:
            print(n)
            break
else:
    x = M//(M//N)
    for i in range(M):
        i = x +i
        if M % i == 0:
            print(M//i)
            break

Solution (Python):
def primeFactor(N):
    i = 2
    ret = {}
    n = N
    if n < 0:
        ret[-1] = 1
        n = -n
    if n == 0:
        ret[0] = 1
    while i**2 <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
            ret[i] = k
        i += 1
    if n > 1:
        ret[n] = 1
    return ret

def isPrime(N):
    if N <= 1:
        return False
    return sum(primeFactor(N).values()) == 1

def findPrime(N):
    if N < 0:
        return -1
    i = N
    while True:
        if isPrime(i):
            return i
        i += 1

def divisor(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return sorted(ret)
    
N, M = map(int, input().split(" "))

for i in divisor(M):
    if i >= N:
        print (M//i)
        break

Solution (Python):
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]))

Solution (Python):
import math
n,m = map(int,input().split())	
r = m
k = 0
a = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]
for i in range(len(a)):
    if m%a[i] == 0 and m >= a[i]:
        r = m//a[i]
        break
if r == m and m >= 199:
    r = m//199
if n > r:
    k = 1

while n <= r :
    if m % n == 0:
        break
    n += 1
if n == r + 1 or k == 1:
    print(1)
else:
    print(m//n)

Solution (Python):

N,M=map(int,input().split())
B=int((M**(1/2))//1)
A=[M//i for i in range(1,int((M**(1/2)+1)//1))]+list(range(1,B))
A.sort(reverse=True)
for i in A:
    flag=M-N*i
    if flag%i==0 and flag>=0:
        print(i)
        break

Solution (Python):
import math
N, M = map(int, input().split())
ulim = M//N
mid = int(math.sqrt(M))
if ulim >= mid:
    ans = []
    for i in range(1, mid+1):
        if M%i == 0:
            ans.append(i)
            if M//i <= ulim:
                ans.append(M//i)
    print(max(ans))

else:
    for i in reversed(range(1, ulim+1)):
        if M%i == 0:
            print(i)
            break

Solution (Python):
import math
N, M = map(int,input().split())
j=1
for i in range(1, int(math.sqrt(M))+2):
    if M%i==0:
        if i <= M//N and j < i:
            j=i
        if M//i <= M//N and j < M//i:
            j=M//i
print(j)

Solution (Python):
n,m=[int(x) for x in input().split()]
import sys
if n==1:
    print(m)
    sys.exit()
ans=1
index=2
while True:
    tmp=index
    if tmp*n>m:
        break
    if m%tmp==0:
        ans=index
    index+=1
print(ans)

Solution (Python):
import numpy as np
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]

def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a
def yaku(n):
    fct = factorize(n)
    y = divisorize(fct)
    ys = []
    for yy in y:
        ys.append(num(yy))
    ys.sort()
    return ys

n,m = list(map(int,input().split()))
if n == 1 and m == 1:
    print(1)
else:
    y = yaku(m)
    print(np.max(np.array(y)[np.array(y) <= m/n]))

Solution (Python):
n, m = [int(i) for i in input().split()]

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

Solution (Python):
def factorize(M):
    fact=[]
    for i in range(2,10**5):
        tmp=[1]
        if M==1:
            break
        while M%i==0:
            M//=i
            tmp.append(tmp[-1]*i)
        if len(tmp)>1:
            fact.append(tmp)
    if M!=1:
        fact.append([1,M])
    return fact

def divisor(fact,arr,i,p):
    if i == len(fact):
        arr.append(p)
        return 0
    for x in fact[i]:
        divisor(fact,arr,i+1,p*x)
    
N,M=list(map(int,input().split()))

fact = factorize(M)
arr=[]
divisor(fact,arr,0,1)
arr=sorted(arr)
ans=1
for x in arr:
    if x>M//N:
        break
    ans=x
print(ans)

Solution (Python):
import math

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

ys = []

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

ys2 = ys.copy()

for y in reversed(ys):
    ys2.append(m // y)

for y in reversed(ys2):
    if y <= m // n:
        print(y)
        break

Solution (Python):
N,M = map(int, input().split())

if M%N == 0:
    ans = M//N
else:
    for i in range(M//N, 0, -1):
        ama = M - i*N
        if ama%i==0:
            ans = i
            break

print(ans)

Solution (Python):
n,m=map(int,input().split())
nums = []
target = m

for i in range(1,pow(10,9)+1):
  if m <= i*i:
    break
  if target % i == 0:
    nums.append([i,target//i])
  if target == 1:
    break

keep = 0
for x in range(len(nums)):
  if n <= nums[x][0]:
    print(nums[x][1])
    exit()
  elif n <= nums[x][1]:
    keep = nums[x][0]
if 0 < keep:
  print(keep)
else:
  print(1)

Solution (Python):
n, m = [int(_) for _ in input().split()]

devs = []
for i in range(1,int((m+1) ** (1/2))+1):
    if m % i == 0:
        devs.append(i)
        devs.append(m // i)

devs = sorted(list(set(devs)), reverse=True)

for dev in devs:
    if m // dev >= n:
        print(dev)
        break

Solution (Python):
import itertools


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 factorize_list(n):
    result = []
    for val,perm in factorize(n):
        result+= [val]*perm
    return result



def mul(args):
    r =1
    for v in args:
        r*= v
    return r

def getcomb(l):
    if len(l)==0:
        return [1]
    result = []
    v,perm = l[0]
    for i in range(perm+1):
        result+= [(v**i)*val for val in getcomb(l[1:])]
    return result


N,M=list(map(int,input().split()))
factorized = factorize(M)
result=1
for i in range(len(factorized)//2+1):
    for vals in getcomb(factorized):
        A= vals
        B= M//A
        
        if A>=N:
            result = max(B,result)
        if B>=N:
            result = max(A,result)


print(result)

Solution (Python):
from math import sqrt
N,M = map(int,input().split(" "))

div = []
l = int(sqrt(M))+1
ans = (1)
for j in range(1,l):
    if M % j == 0:
        if j * N <= M:
            ans = max(ans,j)
        if (M//j) * N <= M:
            ans = max(ans,(M//j))


print(ans)

Solution (Python):
N, M = map(int, input().split())
ans = 1
for i in range(N, min(M+1, 100000)):
    q, m = divmod(M, i)
    if m==0:
        ans = q
        break
else:
    for i in range(100000, 0, -1):
        q, m = divmod(M, i)
        if q < N: continue
        if m==0:
            ans = i
            break
print(ans)

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

Solution (Python):
import math

def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    M = int(buflist[1])
    max = 1
    for i in get_divisor_list(M):
        
        if M % i == 0 and M / i >= N:
            max = i
    print(max)


def get_divisor_list(num):
    div_list = [1, num]
    limit = int(math.sqrt(num))
    for i in range(2, limit+1):
        if num % i == 0:
            div_list.append(i)
            div_list.append(int(num / i))
    return sorted(div_list)

if __name__ == '__main__':
    main()

Solution (Python):
import math

N, M = list(map(int, input().split()))
x = M // N
Mx = []
m = math.floor(math.sqrt(M))
for i in range(1, m + 1):
	if M % i == 0:
		Mx.append(i)

y = len(Mx)

My = []
for i in range(y):
	My.append(int(M // Mx[- 1 - i]))



for i in range(y):
	Mx.append(My[i])

ans = 1
for i in Mx:
	if i <= x:
		ans = i
	else:
		break

print(ans)

Solution (Python):

from sys import stdin
from math import sqrt, ceil

s_in = lambda: stdin.readline()[:-1] 
d_in = lambda: int(stdin.readline()) 
ds_in = lambda: list(map(int, stdin.readline().split())) 

N, M = ds_in()

def factorize(n):
    fct = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            fct.append(i)
            fct.append(n//i)
    fct.sort()
    return fct

cand = factorize(M)
for c in cand[::-1]:
    if M//c >= N:
        print(c)
        exit()

Solution (Python):
def main():
    n, m = map(int, input().split())

    c, div = 1, []
    while c * c <= m:
        if not m % c:
            div.append(c)
            if m // c != c:
                div.append(m//c)
        c += 1

    div.sort(reverse=True)
    for g in div:
        if n <= m // g:
            print(g)
            exit()


if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())
x=1
if n==1:
    x=m
else:
    for i in range(1,100000000):
        if m%i==0 and i*n<=m:
            x=i
print(x)

Solution (Python):





"""
RC112 D
"""

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

from collections import deque
from math import sqrt
def divisors(x):
    divs = deque()
    sq = int(sqrt(x))
    if sq**2 == x:
        divs.append(sq)
        sq=sq-1
    for i in range (sq,0,-1):
        if x%i==0:
            divs.appendleft(i)
            divs.append(x//i)
    return(divs)


cand = [i for i in divisors(m) if n*i<= m]
print(max(cand))

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

maxDivisor = 1
for i in range(1, 100001):
    if m % i == 0:
        if i >= n:
            print(m // i)
            exit()
        else:
            if (m // i) >= n: 
                maxDivisor = i
else:
    print(maxDivisor)

Solution (Python):
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

Solution (Python):
iipt=lambda:int(input())
miipt=lambda:map(int,input().split(" "))
from math import sqrt
n,m=miipt()
r=0
for g in range(1, int(sqrt(m)+1)):
    if m%g==0 and m//g>=n:
        r=max(r, g)
    if m%g==0 and g>=n:
        r=max(r, m//g)
print(r)

Solution (Python):
N,M=map(int,input().split())

if M%N==0:
  print(M//N)
else:
  ans= (M//N)
  cnt=[]
  for i in range(1,M):
    if i*i > M:
      break
    if M%i==0:
      cnt.append(i)
      cnt.append(M//i)
      
  cnt.sort(reverse=True)
  for j in range(len(cnt)):
    if cnt[j] < ans:
      ans=cnt[j]
      break
  
  print(ans)

Solution (Python):
import math
N,M=list(map(int, input().strip().split()))
i=1
ylist1=[]
ylist2=[]
for i in range(1,int(math.sqrt(M))+1):
    if M%i==0:
        ylist1.append(i)
        ylist2.append(M//i)
ylist=ylist2+ylist1[::-1]
nm=M//N
for i in ylist:
    if i<=nm:
        break
print(i)

Solution (Python):
N, M = map(int, input().split(" "))
flg = 0
for i in range(N, M+1):
    if M % i == 0:
        print (M//i)
        flg = 1
        break
    if i**2 > M:
        break

if flg == 0:
    for i in range(M//N, 0, -1):
        if M % i == 0:
            print (i)
            break

Solution (Python):
from collections import defaultdict
from math import sqrt
from fractions import gcd

n, m = [int(i) for i in input().split()]

def factorize(n):    
    i = 2
    A = defaultdict(int)
    
    while n % i == 0:
        n //= i
        A[i] += 1
    i += 1

    while n != 1 and i <= sqrt(n):
        while n % i == 0:
            n //= i
            A[i] += 1
        i += 2
    if n != 1:
        A[n] = 1

    return A

D = set()
F = list(factorize(m).items())
l = len(F)

memo = dict()

def dfs(i, j, k):
    if (i, j, k) in memo:
        return None
    memo[i, j, k] = True
    if i == l:
        D.add(k)
        return None

    if F[i][1] > j:
        dfs(i, j+1, k*F[i][0])
    dfs(i+1, 0, k)
    
    return None

dfs(0, 0, 1)

D = sorted(list(D), reverse=True)
ans = 1

for d in D:
    if m // n < d:
        continue

    ans = max(ans, gcd(d, m-(d*(n-1))))

print(ans)

Solution (Python):
import math

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

factors = []

for i in range(1,int(math.sqrt(M))+10):
	if M % i == 0:
		factors.append(i)
		factors.append(M//i)

ans = 1
for i in factors:
	if N <= M // i:
		ans = max(i,ans)
print(ans)

Solution (Python):
N, M = map(int, input().split())

def primefactorize(n):
    fct = []  
    p, power = 2, 0
    while p * p <= n:
        while n % p == 0:
            n = n // p
            power += 1
        if power > 0:
            fct.append([p, power])
        if p == 2:
            p += 1
        else:
            p += 2
        power = 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]

def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

if M != 1:
    fct = primefactorize(M)
    factors = []
    for div in divisorize(fct):
        factors.append(num(div))
else:
    factors = [1]
factors.sort()
k = M//N
L = [x for x in factors if x <= k]
print(max(L))

Solution (Python):
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]


def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(1, 100):
            if num % i == 0:
                divisor_list.append(i)
                divisor_list.append(num//i)
        for i in range(2, num // 100 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return sorted(divisor_list)


n,m = ai()
d = make_divisor_list(m)
d = d[::-1]
for k in d:
    if m/k == m//k and m//k >= n:
        print(k)
        exit()
print(1)

Solution (Python):
import math
n,m = map(int,input().split())
MAX = m//n
ans = 1
def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff
def divisor_sub(p, q):
    a = []
    for i in range(0, q + 1):
        a.append(p ** i)
    return a

def divisor(n):
    if n == 1:
      return([1])
    xs = factorization(n)
    ys = divisor_sub(xs[0][0], xs[0][1])
    for p, q in xs[1:]:
        ys = [x * y for x in divisor_sub(p, q) for y in ys]
    return sorted(ys)
a = divisor(m)
for i in a:
  if i <= MAX:
    ans = i
print(int(ans))

Solution (Python):
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))

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

cands = []
for i in range(1, int(m**(1/2))+1):
    if m%i == 0:
        cands.append(i)
        cands.append(m//i)
cands = sorted(cands, reverse = True)


for c in cands:
    if m//c >= n:
        print(c)
        break

Solution (Python):
n,m = map(int, input().split() )
c = []


for i in range(1,int(m**0.5)+1) :

   if m%i==0 :
      c.append(i)
      c.append(m//i)

c.sort()
c.reverse()

for j in range(len(c)) :

   if c[j] <= m//n :
      print(c[j])
      break

Solution (Python):
n,m = 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

Solution (Python):

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

res = 1


for i in range(1, min(10**5, M+1)):
    if M % i == 0:
        if i >= N:
            res = max(res, M // i)
        if M // i >= N:
            res = max(res, i)
print(res)

Solution (Python):
import math
N, M = list(map(int,input().split()))
arr = []
arr_inv = []
M_new = int(math.sqrt(M))+1
for i in range(1,M_new):
    if M % i == 0:
        if i == M // i:
            arr.append(i)
        else:
            arr.append(i)
            arr_inv.append(M // i)
arr_inv.reverse()
arr = arr + arr_inv
for i in range(len(arr)):
    if arr[i] >= N:
        print(M // arr[i])
        break

Solution (Python):
N,M=map(int,input().split())

for g in range(M//N,0,-1):
    if (M-(N-1)*g)%g==0:
        break

print(g)

Solution (Python):
import math

def div(x):
	d=[]
	for i in range(int(math.sqrt(x))):
		if x%(i+1)==0:
			d=d+[i+1]
			d=d+[x//(i+1)]
	return d

N,M=map(int,input().split())
d=div(M)
dmax=-1
for i in range(len(d)):
	if d[i]<=M//N:
		if d[i]>dmax:
			dmax=d[i]
print(dmax)

Solution (Python):
N,M = map(int,input().split())

divisors = set()
d = 1
while d*d <= M:
    if M%d == 0:
        divisors.add(d)
        divisors.add(M//d)
    d += 1

ans = 0
for d in divisors:
    a = M//d
    if a >= N:
        ans = max(ans,d)
print(ans)

Solution (Python):


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


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]

def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


try:
    fct = factorize(M)
    L   = []
    for div in divisorize(fct):
        L.append(num(div))
except:
    L = [1, M]

L.sort()
L.reverse()

for l in L:
    if l * N <= M and M % l == 0:
        print(l)
        break

Solution (Python):
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



if __name__ == '__main__':
	run()

Solution (Python):
n,m=map(int,input().split())
def divisor(n): 
    f=[]
    d=[1]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    for i in range(len(f)):
        t=[]
        for j in range(1,f[i][1]+1):
            t.append(f[i][0]**j)
        for j in range(len(d)):
            for k in range(len(t)):
                d.append(d[j]*t[k])
    return sorted(d)
x=divisor(m)
if len(x)==1:
    print(1)
elif n==1:
    print(m)
else: 
    for i in range(len(x)):
        if m/x[i]<n:
            print(x[i-1])
            break

Solution (Python):
import math

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

q = m // n

ret = 0
for i in range(1, int(math.sqrt(m))+1):
    if m % i == 0:
        if i <= q and ret < i:
            ret = i
        p = m//i
        if m//i <= q and ret < p:
            ret = p
print(ret)

Solution (Python):
N, M = map(int, input().split())

X = M // N
for x in range(X, 1, -1):
    r = M - x * (N - 1)
    if r % x == 0:
        print(x)
        exit()
print(1)

Solution (Python):
n, m = map(int, input().split())
 
for i in range(m//n, 0, -1):
    if m % i != 0:
        continue
    print(i)
    break

Solution (Python):

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]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

ans_list = []
m,n = map(int, input().split())
if m == 1 and n == 1:
    print(1)
else:
    fct = factorize(n)
    for div in divisorize(fct):
        ans_list.append(num(div))
    ans_list.sort()
    for number in ans_list:
        if number <= (n//m):
            ans = number
    print(ans)

Solution (Python):
import sys
import math
N,M = map(int, input().split())
if N==1:
  print(M)
  sys.exit()
tmax = int(M/N)
t = tmax
divisor_list = [1]
for i in range(2, int(math.sqrt(M)) + 1):
  if M % i == 0:
    divisor_list.append(i)
    divisor_list.append(M//i)
divisor_list.sort(reverse = True)
for nums in divisor_list:
  if nums <= tmax:
    print(nums)
    sys.exit()

Solution (Python):


from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

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

ans = 1

i = 1
while True:
    if i * i > M:
        break
    if M % i == 0:
        if i >= N:
            ans = max(ans, M / i)
        if M / i >= N:
            ans = max(ans, i)
    i += 1
print ans

Solution (Python):
from math import sqrt
from bisect import bisect
n,m = (int(i) for i in input().split())
x = []
for i in range(1,int(sqrt(m))+1):
	if m%i==0:
		x.append(i)
		x.append(m//i)
x.sort()
print(x[bisect(x,m//n)-1])

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return 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()


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)

Solution (Python):
import math
lis = []
n,m = map(int,input().split())
for i in range(1,math.ceil(math.sqrt(m))+1):
  if m % i == 0:
    lis.append(i)
    lis.append(m//i)
lis.sort()
cou = 0
ans = 0
for i in range(len(lis)):
  if m % lis[i] == 0 and m // lis[i] >= n:
    ans = max(ans,lis[i])
print(ans)

Solution (Python):






n,m=[int(i) for i in input().split()]

yaku1=[]

for i in range(1,10**5):
    if m%i==0:
        yaku1.append(i)

yaku2=[]
for i in yaku1:
    if m//i not in yaku1:
        yaku2.append(m//i)

yaku=yaku1+yaku2


print(max([i for i in yaku if m//i >= n]))

Solution (Python):
n, m = map(int, raw_input().split())

target = m / n

while True:
    if (m - target * n) % target == 0:
        print target
        exit(0)
    target -= 1

Solution (Python):
from sys import stdin
n,m = map(int,stdin.readline().split())
ans = 1
x = 1
a = []
while x * x <=m:
 if m%x==0:
  a.append(x)
  a.append(m/x)
 x+=1
for i in a:
 if m/i >= n:
  ans = max(ans,i)
print ans

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n, m = na()

ds = []
for i in range(1, m+1):
    if i*i > m: break
    if m % i == 0:
        ds.append(i)
        if i*i < m:
            ds.append(m//i)
ds.sort()

for d in ds[::-1]:
    if m//d >= n:
        print(d)
        break

Solution (Python):
n, m = map(int, input().split())

k = m
f = set()
for i in range(1, int(m ** 0.5) + 2):
    d, e = divmod(m, i)
    if e == 0:
        f.add(i)
        f.add(m // i)
ppp = sorted(f)
for p in ppp:
    if p >= n:
        print(m // p)
        break
else:
    print(1)

Solution (Python):


import bisect


def divisors(n):
    ds = []
    for i in range(1, int(n ** 0.5) + 1):
        d, m = divmod(n, i)
        if m == 0:
            ds.append(i)
            ds.append(d)
    ds.sort()
    return ds


def find_ge(a, x):
    i = bisect.bisect_left(a, x)
    if i != len(a):
        return a[i]
    raise ValueError


def solve(n, m):
    ds = divisors(m)
    t = find_ge(ds, n)
    return m // t


def main():
    n, m = (int(z) for z in input().split())
    res = solve(n, m)
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
n, m = map(int, raw_input().strip().split())
div = []
for i in xrange(1, int(m ** 0.5) + 1):
    if i * i == m: div.append(i)
    elif m % i == 0:
        div.append(i)
        div.append(m // i)
div.sort()

ans = 1
for d in div:
    if m // d < n:
        break
    else:
        ans = d

print ans

Solution (Python):
from math import sqrt

n, m = map(int, input().split())
l = []
for i in range(1, int(sqrt(m)) + 1):
	if m % i == 0:
		l.append(i)
		l.append(m // i)

ans = 1
for d in l:
	if d * n <= m:
		ans = max(ans, d)

print(ans)