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())
for i in reversed(range(1,m//n+1)):
    if m%i<1:
        print(i)
        exit()

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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    lower.extend(reversed(upper))
    return lower


def main():
    N, M = map(int, readline().split())

    divisor = divisors(M)
    for d in reversed(divisor):
        if M // d >= N:
            ans = d
            break

    print(ans)
    return


if __name__ == '__main__':
    main()

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

def divisor(num):
    max_num = int(sqrt(num))
    divisor_list = []
    for i in range(1, max_num + 1):
        if num % i == 0:
            divisor_list.append(i)
            divisor_list.append(num//i)
    return divisor_list

g_list = divisor(M)
g_list.sort(reverse=True)
ans = 0
for g in g_list:
    if M//g >= N:
        ans = g
        break
print(ans)

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

Solution (Python):
import sys


read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def 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]

def main():
    N, M = map(int, readline().split())
    M_div = divisors(M)
    for div in M_div:
        if div>=N:
            print(M//div)
            break




if __name__ == '__main__':
    main()

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

Solution (Python):
from functools import reduce

def factors(n):
    return set(reduce(list.__add__,
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))


n,m=map(int,input().strip().split(" "))
fact=sorted(factors(m),reverse=True)
ans=1
for i in fact:
    if m//i >=n:
        ans=i
        break
print(ans)

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

Solution (Python):
def main():
    N, M = map(int, input().split())
    maxM = M//N + 1
    for m in range(maxM, 0, -1):
        tmp = m * N
        remain = M - tmp
        check = remain % m
        if check == 0 and remain >= 0:
            print(m)
            return

if __name__ == "__main__":
    main()

Solution (Python):
def main():
    N, M = map(int, input().split())
    search = M//N + 1
    for s in range(search, 0, -1):
        sum_array = s * N
        if sum_array > M:
            continue
        remain = M - sum_array
        if remain % s == 0:
            print(s)
            return

if __name__ == "__main__":
    main()

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

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

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

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

div_list = make_divisors(M)
div_list = div_list[::-1]
for div in div_list:
    if N * div <= M:
        print(div)
        exit()

Solution (Python):
import sys,math,collections,itertools
input = sys.stdin.readline

N,M=list(map(int,input().split()))
mn = M//N
ml = M%N
if ml == 0:
    print(mn)
    exit()
ans = 0
for i in range(mn+1,0,-1):
    if i < ans:
        break
    tmp = math.gcd(i,M-i*(N-1))
    ans = max(ans,tmp)
print(ans)

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

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re












import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m = readInts()
def yaku(m):
    ans = []
    i = 1
    while i*i <= m:
        if m % i == 0:
            j = m // i
            ans.append(i)
            if j != i:
                ans.append(j)
        i += 1
    ans = sorted(ans)
    return ans
ya = yaku(m)

ans = -1
for a in ya:
    if a * n <= m:
        ans = a
    else:
        break
print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
from bisect import bisect_left
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 = [1]+make_divisors(M)
div.sort()
g = div[bisect_left(div, N)]
print(M//g)

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

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

Solution (Python):
import sys
def factors(n):
  a = []
  x = 1
  while x * x <= n :
    if n % x == 0:          
      a.append(x)
      a.append(n//x)
    x += 1
  return a
n,m=map(int,input().split())
fac=factors(m)
fac.sort()
for i in range(len(fac)-1,-1,-1):
  if n*fac[i]<=m:
    print(fac[i])
    sys.exit()

Solution (Python):





import math
import fractions
import sys
import bisect
import heapq  
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr



def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod



def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


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


inf = 10 ** 18
mod = 10 ** 9 + 7

n,m = lr()
f = make_divisors(m)
f.reverse()
for num in f:
    if num * n <= m:
        print(num)
        sys.exit()

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

divisors = make_divisors(M)
ans = 0
for d in divisors:
    if N*d <= M:
        ans = d

print(ans)

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

def solve():
  N, M = map(int, input().split())
  cd = divisor(M)
  cd.sort()
  for c in cd:
    if c<=M//N:
      ans = c
  return ans
print(solve())

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

if __name__ == '__main__':
    main()

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

Solution (Python):
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]
  
d = make_divisors(M)
d = list(filter(lambda x:x<=M/N,d))

print(d[-1])

Solution (Python):
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 d in cd:
  if M//d>=N:
    print(d)
    break

Solution (Python):
def divisor(n):
    i = 1
    res = set()
    for i in range(1, int(n**.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)
            exit()

if __name__ == '__main__':
    main()

Solution (Python):
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 = map(int, input().split())
    md = divisor(m)
    ans = 0
    for i in md:
        if i*n <= m:
            print(i)
            exit()

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
from itertools import *
n,m=map(int,input().split())
M=m
a=[1]
for i in range(2,int(m**.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)

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()

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

    
    ans = 1
    for i in M_div:
        if M // i >= N:
            ans = max(i, ans)

    print(ans)

if __name__ == '__main__':
    resolve()

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

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

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

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

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(reverse=True)
  return divisors

numbers = make_divisors(m)
for i in range(len(numbers)):
  if numbers[i] <= m/n:
    print(numbers[i])
    break

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re












import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m = readInts()
def yaku(m):
        ans = []
        i = 1
        while i*i <= m:
            if m % i == 0:
                j = m // i
                ans.append(i)
                if j != i:
                    ans.append(j)
            i += 1
        ans = sorted(ans)
        return ans
a = yaku(m)
for i in range(len(a)):
    if n*a[i] <= m:
        ans = a[i]
    else:
        break
print(ans)

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

if __name__ == "__main__":
    main()

Solution (Python):
n,m=map(int,input().split())
d=[]
f=1
while f*f<m+1:
  if m%f==0:
    d.append(f)
    d.append(m//f)
  f+=1
d.sort(reverse=True)
for i in d:
  if  (m-i*n)>=0 and (m-i*n)%i==0 :break
print(i)

Solution (Python):
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 = map(int, input().split())

    divisors = calc_divisors(M)
    ans = 0
    for divisor in divisors:
        if M // divisor >= N:
            ans = max(ans, divisor)

    print(ans)


if __name__ == "__main__":
    main()

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

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


import sys
input = sys.stdin.readline  
N,M = (int(i) for i in input().split())
M_div =make_divisors(M)
div_rev =M_div[::-1]


for i in range(len(M_div)):
    if N <= M_div[i]:
        print(div_rev[i])

        break

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

Solution (Python):
N,M = map(int,input().split())
def yakusu(n):
    ans=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            ans.append(i)
            if n!=i**2:
                ans.append(n//i)
    return ans

y = yakusu(M)
print(max(k for k in y if k*N<=M))

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








ans = 1
for i in range(1, math.floor(M**0.5)+1):
  if M % i == 0:
    if M//i <= M//N:
      ans = max(ans, M//i)
    elif i <= M//N:
      ans = max(ans, i)
print(ans)

Solution (Python):
import math
N, M = [int(i) for i in input().split()]
for i in range(M//N, 0, -1):
  if M % i == 0:
    print(i)
    break

Solution (Python):
import math
N, M = [int(i) for i in input().split()]
for i in range(math.ceil(M/N), 0, -1):
  if M % i == 0:
    print(i)
    break

Solution (Python):


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


"""
O(N ** 0.5)で計算できる約数列挙

N = 20
make_divisors(20) = [1,2,4,5,10,20]
"""


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)

Solution (Python):
n, m = map(int, input().split())
a, r = divmod(m, n)
while True:
    r = m%a
    if r == 0:
        break
    a -= 1
print(a)

Solution (Python):
n,m=map(int,input().split())
a=[]
for i in range(1,int(m**.5)+1):
  if m%i==0:
    ans=i
    a.append(i)
  if i==m//n:break
else:
  for i in a:
    if m//i<=m//n:
      ans=m//i
      break
print(ans)

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

Solution (Python):
from math import gcd

def solve():
    n, m = map(int, input().split())
    d = m // n
    p = m % n
    res = max(1, gcd(d, d + p))
    if p == 0:
        print(res)
        exit()
    while d > res:
        d -= 1
        p += n
        if p % d == 0:
            res = max(res, d)
    print(res)


solve()

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


if __name__ == "__main__":
    main()

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

Solution (Python):


import math

import itertools
from collections import deque
from collections import Counter



import bisect

n,m=map(int,input().split())
x=int(pow(m,0.5))
res=[]
for i in range(1,x+1):
    if m%i==0:
        res.append(i)
        if i!=m//i:
            res.append(m//i)
res.sort()
ans=bisect.bisect_left(res,n)
print(m//res[ans])

Solution (Python):
from collections import deque

N, M = 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

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

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 = map(int, input().split())

if n % m == 0:
  print(int(n/m))
  exit()
else:
  lst = make_divisors(m)[::-1]
  for i in lst:
    if i == 1:
      print(i)
      exit()
    if m - i*(n-1) > 0:
      if (m - i*(n-1)) % i == 0:
        print(i)
        exit()
    else:
      continue

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

if n == 1:
    print(m)
    exit()
a = []
b = []
for i in range(1, math.ceil(math.sqrt(m))):
    if m % n == 0:
        print(m // n)
        exit()
    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))

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

if m//n == m/n:
    print(m//n)
else:
    ans = 1
    for i in range(2,min(m,10**8+1)):
        if m-i*(n-1) < i:
            break
        if m%i == 0:
            ans = i
    print(ans)

Solution (Python):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



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

i = 1

divs = []
while i ** 2 <= M:
    if M % i != 0:
        i += 1
        continue
    divs.append(i)
    divs.append(M // i)
    i += 1
divs = sorted(divs)
ans = 1
for d in divs:
    if N <= M // d:
        ans = max(d, ans)
print(ans)

Solution (Python):
import sys

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

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



divisor = []  

for i in range(1,int(M**.5)+1):
    if M % i == 0:
        divisor.append(i)
        if i != M//i:
            divisor.append(M//i)

ANS = []

for d in divisor:
    if d >= N:
        ANS.append(M//d)

print(max(ANS))

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

def f(n,m):
	if n == 1:
		return m
	divisors = []
	for d in range(2, int(m ** 0.5)+1)[::-1]:
		if m % d == 0:
			divisors.append(d)
			if d != m/d: divisors.append(m/d)
	divisors.sort(key = lambda x:-x)
	for d in divisors:
		if m/d >= n:
			return d

	return 1

print f(n,m)

Solution (Python):
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N,M=mi()

    def 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

    D = divisors(M)
    ans = 1
    for d in D:
        X = M // d
        if X-N+1 > 0:
            ans = max(ans,d)
    
    print(ans)




if __name__ == "__main__":
    main()

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

max_ = 1
for n in range(int(M / N) + 1, 0, -1):
    d = (M - N * n)

    if d >= 0 and d % n == 0:
        max_ = n
        break

print(max_)

Solution (Python):
from math import sqrt
from bisect import bisect_left

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


t = M

for i in range(1,int(sqrt(M))+2,1):
    if M % i ==0:
        count = 0
        if M % i == 0:
            if N <= i and i <= t:
                t = i
            if N <= M//i and M//i <= t:
                t = M//i

print(M//t)

Solution (Python):
[n,m] = [int(i) for i in input().split()]
if n == 1:
    print(m)
else:
    ans = -1
    
    a1_max = m // n
    for i in range(a1_max,0,-1):
        if (m - i) % i == 0 and (m - i)//i >= (n-1):
            ans = max(ans,i)
    print(ans)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

def dv(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 = I()
ans = 0
for d in dv(M):
    if M//d >= N:
        ans = max(ans,d)
print(ans)