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):
def func(M):
    num = []
    for i in range(1, int(M**0.5)+1):
        if not M % i:
            num.append(i)
            num.append(M//i)

    num.sort()
    return num

N, M = list(map(int, input().split()))
ans = 1
x = M / N

num = func(M)

for n in num:
    if n <= x:
        ans = n
    else:
        break
print(ans)

Solution (Python):
N, M = map(int, input().split())
result = 1
i = 1
while i * i <= M:
    if M % i == 0:
        for d in [i, M // i]:
            if M // d >= N:
                result = max(result, d)
    i += 1
print(result)

Solution (Python):
def f(x):
    ret=[]
    for i in range(1,int(x**0.5)+1):
        if x%i==0:
            ret+=[i,x//i]
    ret.sort()
    return ret

N,M=map(int,input().split())
divitors=f(M)
for m in divitors:
    if m<N:pass
    else:
        print(int(M/m))
        break

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

Solution (Python):
import math
N, M = map(int, input().split())
mx = 0
for i in range(1, math.floor(math.sqrt(M))+1):
    if M % i == 0:
        if M // i >= N:
            mx = max(mx, i)
        if i >= N:
            mx = max(mx, M//i)
print(mx)

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

div = []
for m in range(1, int(M ** (0.5) + 1)):
    if M % m == 0:
        div.append(m)
        if m != M // m:
            div.append(M // m)
            
div.sort()
for i in range(len(div)):
    if div[-i-1] * N <= M:
        print(div[-i-1])
        break

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

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

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

Solution (Python):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append([i,n//i])
            if i != n // i:
                divisors.append([n//i, i])

    
    return divisors

N, M = map(int, input().split())
ceil = M // N
divisors = make_divisors(M)
divisors.sort(reverse=True)
for i,j in divisors:
    if j >= N:
        print(i)
        break

Solution (Python):
N, M = map(int, input().split())
ceil = M // N
for i in range(1,ceil+1)[::-1]:
    tmp = M - i * (N - 1)
    if tmp > 0 and tmp % i == 0:
        print(i)
        break

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

d = []
i = 1
while i**2 < M:
    if M%i == 0:
        d.append(i)
        d.append(M//i)
    i += 1
if i**2 == M:
    d.append(i)
d.sort()

ans = 1
for i in range(len(d)):
    if d[i]*N <= M:
        ans = d[i]
print(ans)

Solution (Python):
def div(num):
  ret=[]
  for i in range(1,int(num**0.5)+1):
    if num%i==0:
      ret.append(i)
      if i!=num//i:
        ret.append(num//i)
  return ret

n,m=map(int,input().split())
div_list=div(m)
div_list=sorted(div_list,reverse=True)
ans=0
for i in div_list:
  if (m-i*n)%i==0 and m>=i*n:
    ans=i
    break
print(ans)

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

divisor_array = []
divisor_max = math.floor(math.sqrt(M))

for i in range(1, divisor_max + 1):
    if M % i == 0:
        divisor_array.append(i)
        divisor_array.append(M // i)

divisor_array.sort()


insert_index = bisect.bisect_left(divisor_array, N)

print(M // divisor_array[insert_index])

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

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** .5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort()
    return divisors

divs = make_divisors(m)
d = [x for x in divs if x >= n][0]
print(m // d)

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

Solution (Python):
import math

n,m = map(int, input().split())
yakusu=[]
for i in range(1, int(math.sqrt(m))+1):
	if m % i == 0:
		yakusu.append(i)
		if i*i != m:
			yakusu.append(m//i)
			
ans=0
for i in yakusu:
	if m//i >= n:
		ans = max(i, ans)
		
print(ans)

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

for i in make_divisors(M):
    if i <= M // N:
        ans = i 

print(ans)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    return


def B():
    return


def C():
    n = II()
    xyh = LIR(n)
    xyh.sort(key = lambda x:x[2], reverse = True)
    x1, y1, h1 = xyh[0]
    del xyh[0]
    for x in range(101):
        for y in range(101):
            h = abs(x - x1) + abs(y - y1) + h1
            flg = True
            for xn, yn, hn in xyh:
                if max(h - abs(x - xn) - abs(y - yn), 0) == hn:
                    continue
                flg = False
                break
            if flg:
                print(x, y, h)
                return 
    return


def D():
    n, m = LI()
    ans = 1
    for i in range(1,int(math.sqrt(m)+1)):
        if m % i == 0:
            a = m // i
            
            if a * n <= m:
                ans = max(ans, a)
            if i * n <= m:
                ans = max(ans, i)
    print(ans)
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    D()

Solution (Python):
import math
def divisor(n):
    res = []
    for i in range(1,int(math.sqrt(n))+2):
        if n % i == 0:
            res.append(i)
            if n // i != i:
                res.append(n // i)
    return res
    
N, M = map(int, input().split())
maxd = 0
for d in divisor(M):
    if M // d >= N:
        maxd = max(maxd, d)
print(maxd)

Solution (Python):
import bisect
n,m=map(int,input().split())
l=[]
for i in range(1,int(m**0.5)+1):
    if m%i==0:l.extend([i,m//i])
l.sort()
print(l[bisect.bisect_right(l,m/n)-1])

Solution (Python):
n,m=map(int,input().split())
a=1
for i in range(1,min(int(m**0.5),m//n)+1):
    if(m%i==0):
        if(i>=n):
            a=m//i
            break
        else:
            a=i
print(a)

Solution (Python):

import math
N, M = map(int, input().split())
ans = 0
for a in range(1, int(math.sqrt(M))+1):
    if M % a != 0:
        continue
    b = int(M / a)
    if a * N <= M:
        ans = max(ans, a)
    if b * N <= M:
        ans = max(ans, b)
print(ans)

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

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

if N==1:
    print(M)
else:
    ans = 1
    for i in range(1,10**5):
        if i*i>M:
            break
        if M%i==0:
            j=0
            k=0
            if M//i>=N:
                j=i
            if i>=N:
                k=M//i
            ans = max(j,k,ans)

    print(ans)

Solution (Python):

















import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque

from itertools import product

from itertools import permutations

from itertools import combinations
from bisect import bisect_left, bisect_right


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")
MAX_DIGIT = 50





N, M = l_inpl()

ans = 1

for k in range(1, int(M**0.5)+1):
    if k*N <= M:
        if M % k == 0:
            ans = max(ans, k)
            if k**2 == M:
                continue
            if (M//k)*N <= M:
                ans = max(ans, M//k)

print(ans)

Solution (Python):
N,M = 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)

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

Solution (Python):

import sys
import bisect
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, M: int):
    ds = []
    for i in range(1, int(ceil(sqrt(M))) + 1):
        if M % i == 0:
            ds.append(i)
            ds.append(M // i)
    ds.sort()
  
    th = M // N
    return ds[bisect.bisect(ds, th)-1]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    result = solve(N, M)
    print(result)

if __name__ == '__main__':
    main()

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

import math

def divisor(M):
    divisor_list = []
    for num in range(1, math.ceil(math.sqrt(M)) + 1):
        if M % num == 0:
            divisor_list.append(num)
    return divisor_list
  
candidate = []
for num in divisor(M):
    M_k, M_sigmaB = num, M // num
    M_k2, M_sigmaB2 = M // num, num
    
    if M_sigmaB >= N:
        candidate.append(M_k)
    if M_sigmaB2 >= N:
        candidate.append(M_k2)
    
print(max(candidate))

Solution (Python):
from math import ceil, sqrt

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

Solution (Python):



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

ans = 0
i = 1
while i*i <= M:
    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):
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)

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

for base in range(1, M//N+1)[::-1]:
    if M % base != 0:
        continue
    print(base)
    break

Solution (Python):

"""
D - Partition
https://atcoder.jp/contests/abc112/tasks/abc112_d

"""
import sys


from bisect import bisect_right

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

    div_M = sorted(list(divisor(M)))
    i = bisect_right(div_M, M/N)
    if i:
        return div_M[i-1]
    else:
        return 1



def main(args):
    N, M = map(int, input().split())
    ans = solve(N, M)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):



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

def main():
    N, M = list(map(int, input().split()))
    k = M // N
    divisors = make_divisors(M)
    print([d for d in divisors if d <= k][-1])


if __name__ == '__main__':
    main()

Solution (Python):
import math
a_list = []
n, m = map(int, input().split())
for i in range(math.ceil(m**(1/2)), 0, -1):
    if m % i == 0:
        a_list.append(i)
        a_list.append(m//i)
border = math.floor(m / n)
a_list = list(reversed(sorted(a_list)))
for aa in a_list:
    if border >= aa:
        ans = aa
        break
print(ans)

Solution (Python):
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 = map(int, input().split())
for d in make_divisors(M):
    if d * N <= M:
        break
print(d)

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


import math
sM = int( math.sqrt(M) + 1 )

ma = 0
for i in range(1,sM):
  if (M%i)==0:
    a,b=i,M//i
    if ( a * N <= M ):
      ma = max(a,ma)
    if ( b * N <= M ):
      ma = max(b,ma)
print (ma)

Solution (Python):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

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())


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)
divs.sort(reverse=True)

ans = 1
for di in divs:
    if m // di >= n:
        ans = di
        break

print(ans)

Solution (Python):


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


F = make_divisors(M)
gcd = 0

for i in range(len(F)):
    if F[i] * N > M:
        break

    gcd = F[i]

print(gcd)

Solution (Python):
N, M = [int(i) for i in 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

divisors = make_divisors(M)
for d in reversed(divisors):
    if M // d >= N:
        print(d)
        break

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

Solution (Python):
import math

n,m = map(int,input().split())
ans = 0
for i in range(1,int(math.sqrt(m))+1):
    if m%i == 0 and i <= m/n:
        if ans < i:
            ans = i
    k = m//i
    if m%k == 0 and k <= m/n:
        if ans < k:
            ans = k

print(ans)

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

print(max([j for i in range(int(M**0.5), 0, -1) for j in [i, int(M/i)] if M % j == 0 and M / N >= j]))

Solution (Python):
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
divs = sorted(make_divisors(M),reverse=True)
for div in divs:
    if N <= M/div:
        print(div)
        break

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

N, M = map(int, input().split())
for i in reversed(div(M)):
    if i <= M//N:
        print(i)
        break

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

div = []
for i in range(1, int(M**0.5)+1):
  if M % i == 0:
    div.append(i)
    if M // i != i:
      div.append(M // i)
div.sort()

for i in range(len(div)):
  num = div[i]
  if num >= N:
    print(M // num)
    break

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

Solution (Python):
def divisor(x):
    ret = []
    i = 1
    while i*i <= x:
        if x%i == 0:
            ret.append(i)
            if x//i != i:
                ret.append(x//i)
        i += 1
    return sorted(ret, reverse=True)

n,m = map(int,input().split())
for g in divisor(m):
    if m//g >= n:
        print(g)
        break

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

N,M = [int(x) for x in input().split()]
divisor = make_divisors(M)
ans = 0
for x in divisor:
    if(x>=N):
        ans = M//x
        break
print(ans)

Solution (Python):
n,m=map(int,input().split())
def yak1(n,m):
  l=[]
  for i in range(1,min(int((m)**(1/2))+1,(m//n)+1)):
    if m%i==0:
      l.append(i)
      if m//i!=i and m//i<=m//n:
        l.append(m//i)
  return l
print(max(yak1(n,m)))

Solution (Python):
def make_divisors(n,m):
    divisors = []
    for i in range(1,min(int(m**(1/2))+1,int(m//n)+1)):
      if m % i == 0:
          divisors.append(i)
          if i != m // i and m//i<=m//n:
              divisors.append(m//i)
    return divisors
n,m=map(int,input().split())
print(max(make_divisors(n,m)))

Solution (Python):


from bisect import bisect_left as binl
from copy import copy, deepcopy

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * sy) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance





def main():
    n, m = intin()

    divlist = get_divisors(m)
    divlist.sort()

    for div in divlist:
        if div >= n:
            print(m // div)
            return


if __name__ == '__main__':
    main()

Solution (Python):


from bisect import bisect_left as binl
from copy import copy, deepcopy

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * sy) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance





def get_factors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def main():
    n, m = intin()

    flist = get_factors(m)
    flist.sort()

    for f in flist:
        if f >= n:
            print(m // f)
            return


if __name__ == '__main__':
    main()

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


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


ans = 0
for x in make_divisors(M):
    if N <= M // x:
        ans = max(ans, x)
print(ans)

Solution (Python):
from collections import Counter

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


def factorize(n):
    if n == 1:
        return [1]

    i, factors = 2, []
    while i * i <= n:
        while n % i == 0:
            n //= i
            factors.append(i)
        i += 1
    if n > 1:
        factors.append(n)
    return factors


c = Counter(factorize(M))
a = [1]
for k, v in c.items():
    tmp = []
    for x in a:
        for i in range(v + 1):
            tmp.append(x * (k**i))
    a = list(set(a) | set(tmp))

ans = 0
for x in a:
    y = M // x
    if N <= y:
        ans = max(ans, x)
print(ans)

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

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

ans = 1

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

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

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

Solution (Python):
def make_divisors(n,m):
    divisors = []
    for i in range(1,min(int(m**(1/2))+1,int(m//n)+1)):
      if m % i == 0:
          divisors.append(i)
          if i != m // i and m//i<=m//n:
              divisors.append(m//i)
    return divisors
n,m=map(int,input().split())
print(max(make_divisors(n,m)))

Solution (Python):

import sys

def factoring(n: int):
    factors = []
    p = 1
    while p * p <= n:
        if n % p == 0:
            factors.append(p)
            if n != p * p:
                factors.append(n // p)
        p += 1
    return factors

def solve(N: int, M: int):
    if N == 1:
        print(M)
        return
    F = factoring(M)
    F.sort()
    for f in F:
        if f >= N:
            print(M // f)
            break
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    solve(N, M)

if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int, input().split())
from math import sqrt
d0=[]
for i in range(1,int(sqrt(m)+1)):
    if m%i==0:
        d0.append(i)
d=d0[:]
for di in reversed(d0):
    d.append(m//di)
for i in reversed(d):
    if i<=m//n:
        print(i)
        break

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

a = M // N

for i in range(a,0,-1):
    if M % i == 0:
        print(i)
        exit()

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

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

Solution (Python):
import math
n, m = map(int, input().split())
ans = 1
for k in range(1, math.ceil(math.sqrt(m))):
    l = m // k
    if m % k == 0 and n * k <= m:
        ans = max(k, ans)
    if m % l == 0 and n * l <= m:
        ans = max(l, ans)
print('%d' % ans)

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

while ans > 0:
    if m%ans == 0:
        if m//ans >= n:
            break
    else:
        ans -= 1

print(ans)

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



divisors = []
for d in range(1, M+1):
    if d*d > M:
        break
    if M%d == 0:
        divisors.append(d)
        divisors.append(M//d)

ans = 1

divisors.sort()

for d in divisors:
    if N*d <= M:
        ans = d

print(ans)

Solution (Python):
import math
N, M = map(int, input().split())
ans = 1
for i in range(int(math.sqrt(M))):
    a = i+1
    if M%a != 0:
        continue
    b = M // a
    if M >= N * a:
        ans = max(ans, a)
    if M >= N * b:
        ans = max(ans ,b)
print(ans)

Solution (Python):
import sys
import math
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n, m = nm()
ans = 1
for i in range(1, int(math.sqrt(m)) + 2):
    if m % i == 0:
        if m // i >= n and i >= n:
            ans = max(ans, i, m // i)
        elif m // i >= n:
            ans = max(ans, i)
        elif i >= n:
            ans = max(ans, m // i)
print(ans)

Solution (Python):
from collections import defaultdict
from copy import deepcopy
from math import log

N,M=map(int,input().split())
def prime_factor(n):
    i = 2
    table = defaultdict(int)
    while i * i <= n:
        while n % i == 0:
            n //= i
            table[i]+=1
        i += 1
    if n > 1:
        table[n]+=1
    return table
f=prime_factor(M)
L=[1]
for i in f.keys():
    l=[]
    for j in range(f[i]+1):
        l.extend([k*(i**j) for k in L])
    L=l
L.sort()
for i in L[::-1]:
    if i>=N:
        ans=i
        continue
    break
print(M//ans)

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

if int(math.sqrt(M)) > N:
    divlist = []
    for i in range (N, int(math.sqrt(M))):
        if M%i == 0:
            divlist.append(i)
    
    if divlist != []:
        for i in range(N, int(math.sqrt(M))):
            if M%i == 0:
                ans = M//i
                break
    else:
        for i in range(N,0,-1):
            if M%i == 0:
                ans = i
                break
else:
    for i in range(M//N,0,-1):
        if M%i == 0:
            ans = i
            break
            
print(ans)

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

a = m//n

for i in range(a):
    x = a-i
    if m % x == 0:
        print(x)
        break

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

Solution (Python):
n,m=map(int,input().split())
for i in range(2,m):
  if i*i>m:
    print(1)
    exit()
  if m%i==0:
    break
for i in range(n,m+1):
  if m%i==0:
    print(m//i)
    exit()

Solution (Python):

def main():
    N, M = map(int, input().split())
    yakusuu_list = []

    for i in range(1, int(M ** 0.5) + 1):
        if M % i == 0:
            yakusuu_list.append(i)
            yakusuu_list.append(M // i)
    yakusuu_list.sort(reverse=True)

    for num in yakusuu_list:
        if num * N <= M:
            print(num)
            break

if __name__ == '__main__':
    main()

Solution (Python):
N,M=map(int,raw_input().split())
F=[]
i=1
while i * i <= M:
    if M%i==0:
        F.append(i)
        if i*i!=M: F.append(M/i)
    i+=1

F.sort()    
ans=-1
for k in F:
    if (M/k-N>=0):
        ans=k
print(ans)