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

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

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

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

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

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

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

Difficulty: interview

Starter code:

Solutions:
from bisect import bisect_left,bisect

# ===================================== 約数のリスト   
def enum_div(n):
    ir=int(n**(0.5))+1
    ret=[]
    for i in range(1,ir):
        if n%i == 0:
            ret.append(i)
            if (i!= 1) & (i*i != n):
                ret.append(n//i)
    return ret

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

div=enum_div(m)+[m]
div.sort(reverse=True)

rd=[0]*len(div)
for i in range(len(div)):
    rd[i]=m//div[i]

mm=bisect_left(rd,n)

print((div[mm]))


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

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

if n == 1:
    print(m)
    return
a = []
b = []
for i in range(1, math.ceil(math.sqrt(m))):
    if m % n == 0:
        print((m // n))
        return
    if m % i == 0:
        b.append(i)
        b.append(m // i)
        
#print(b)

for i in range(len(b)):
    if b[i] * n <= m:
        a.append(b[i])
#print(a)

if len(b) == 2:
    print((1))
else:
    print((max(a)))


from math import sqrt,floor
N,M =map(int,input().split())
ans = 1
for g in range(1,floor(sqrt(M))+1):
    if M%g == 0:
        x = M//g
        if x > floor(sqrt(M)) and g >= N:
            ans = x
            break
        if x >= N:
            ans = g
print(ans)

n,m=list(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)


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

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

d=primes(M)

for i in d[::-1]:
    if M//i>=N:
        ans=i
        break

print(ans)


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

import math
G=[]
for i in range(1,int(math.sqrt(M))+2+1):
    if M%i == 0:
        cd = M//i
        G.append(cd)
        G.append(i)

G.sort(reverse=True)
for g in G:
    n = M//g
    if n>=N:
        print(g)
        return









from collections import defaultdict

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

ans = 0
i = 1
while i * i <= m:
    if m % i == 0:
        a, b = i, m // i
        if b >= n:
            ans = max(ans, a)
        if a >= n:
            ans = max(ans, b)
    i += 1
print(ans)


#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
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)


def main():
    import sys

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

    def divisor(m):
        arr = [1, m]
        i = 2
        while i*i <= m:
            if m%i == 0:
                arr.append(i)
                if m//i != i:
                    arr.append(m//i)
            i+= 1
        arr.sort()
        return arr   

    n, m = map(int, input().split())
    a = divisor(m)
    for x in a:
        if x >= n:
            print(m//x)
            return
    

def __starting_point():
    main()
__starting_point()

#!/usr/bin/env python3

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

ans = 1
num = int(m**0.5)+1

for i in range(1, num):
    if m % i != 0:
        continue
    j = m//i
    if i >= n:
        ans = max(ans, j)
    if j >= n:
        ans = max(ans, i)
print(ans)


import sys
def make_divisors(n):
  lower_divisors , upper_divisors = [], []
  i = 1
  while i*i <= n:
    if n % i == 0:
      lower_divisors.append(i)
      if i != n // i:
        upper_divisors.append(n//i)
    i += 1
  return lower_divisors + upper_divisors[::-1]
N,M=map(int,input().split())
c=M//N
L=make_divisors(M)
L=list(reversed(L))
for i in range(len(L)):
  if L[i]<=c:
    print(L[i])
    return

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

from collections import deque

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

a = deque()
b = deque()
for i in range(1, int(M ** (1 / 2)) + 1):
    if M % i == 0:
        a.appendleft(i)
        b.append(M // i)

b.extend(a)

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


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)

def __starting_point():
    main()
__starting_point()

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

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


#約数
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]

#M=約数✖（相手）⇒相手＝n(n+1)/2 以上なら成り立つ
for i in range(len(M_div)):
    if N <= M_div[i]:
        print(div_rev[i])

        break 


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


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

    divisors.sort()
    return divisors


b = make_divisors(m)
# print(b)
a = m//n
# print(a)
ans = 0
for i in b:
    if i <= a:
        ans = i
print(ans)


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

n,m=nii()

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

d=divisore(m)

for x in d:
  zan=m-(x*n)
  if zan>=0 and zan%x==0:
    print(x)
    return

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

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

P=[]
A=round(M**0.5)+2
for i in range(1,A):
    if M%i==0:
        P.append(i)
        P.append(M//i)
P.sort()

B=M//N
ans=now=1
for p in P:
    now=p
    if now<=B:
        ans=now
print(ans)

from bisect import bisect_right

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

            ii = n//i
            if ii != i:
                upper_result.append(ii)

    return lower_result + upper_result[::-1]

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

def __starting_point():
    main()
__starting_point()

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

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


import sys

input = sys.stdin.readline


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


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

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

    print(ans)


def __starting_point():
    main()

__starting_point()

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

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


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)

def __starting_point():
    main()
__starting_point()

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)

    # Mの約数の中でMを割った時の値がN以上になるような最大のもの
    ans = 1
    for i in M_div:
        if M // i >= N:
            ans = max(i, ans)

    print(ans)

def __starting_point():
    resolve()

__starting_point()

import sys, math
from functools import lru_cache
from collections import deque
from bisect import bisect_left
sys.setrecursionlimit(10**9)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return list(map(int, input().split()))

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, M = mi()

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

    d.sort()

    for v in d:
        if v <= M//N:
            ans = v
        else:
            break

    print(ans)

    



def __starting_point():
    main()

__starting_point()

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

res = 1
num = int(m ** 0.5) + 1
for i in range(1, num):
    if m % i != 0:continue 
    j = m // i
    if i >= n:
        res = max(j, res)
    if j >= n:
        res = max(i, res)
print(res)


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

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)

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

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


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


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

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

ans = 1
for i in make_divisors(M):
    work1 = i * N
    work2 = M - work1
    if work2 >= 0 and work2 % i == 0:
        ans = max(i, ans)
# print(make_divisors(M))
print(ans)

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

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
  
d = make_divisors(M)
d = list(filter(lambda x:x<=M/N,d))

print(d[-1])

# import itertools
# import math
# from functools import reduce
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np
# import heapq
# from collections import deque

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, M = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

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]

# def gcd_list(numbers):
#     return reduce(math.gcd, numbers)

# if gcd_list(A) > 1:
#     print("not coprime")
#     return

# 高速素因数分解準備
#MAXN = 10**6+10
#sieve = [i for i in range(MAXN+1)]
#p = 2
#while p*p <= MAXN:
#    if sieve[p] == p:
#        for q in range(2*p, MAXN+1, p):
#            if sieve[q] == q:
#                sieve[q] = p
#    p += 1

l = make_divisors(M)

# print(l)

threshold = M / N

for i, d in enumerate(l):
    if threshold < d:
        print(l[i - 1])
        return

print(M)

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


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

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


#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

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)


#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
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)
#print(ya)
ans = -1
for a in ya:
    if a * n <= m:
        ans = a
    else:
        break
print(ans)


N,M = map(int,input().split())
def make_divisors(n):
    divisors = []
    # 試し割りで、かつ積でnを作るときの相方も同時に追加してる
    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
div_ls = make_divisors(M)
ans = 1
for div in div_ls:
    if div*N <= M:
        ans = max(ans,div)
print(ans)

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

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return sorted(lower_divisors + upper_divisors[::-1],reverse=True)

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

#!/usr/bin/env python
# coding: utf-8

# In[11]:


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


# In[12]:


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]


# In[14]:


for x in make_divisors(M)[::-1]:
    if M//x >= N:
        ans = x
        break
print(ans)


# In[ ]:






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


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

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

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

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

print(ans)



def LI():
    return list(map(int, input().split()))


N, M = LI()
x = M//N
for i in range(x, 0, -1):
    if M % i != 0:
        continue
    ans = i
    break
print(ans)

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

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

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


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

def __starting_point():
    main()
__starting_point()

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

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

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

cand = []

for i in range(1, int(sqrt(M))+1):
    if M % i == 0:
        cand.append(i)
        u = M // i
        if u != i:
            cand.append(u)

cand.sort()

ans = 1
for j in cand:
    if N * j <= M:
        ans = max(ans, j)

print(ans)

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


n, m = map(int, input().split())
li = []
#mの約数を求める
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)
#大きい順に公約数を見ていって条件を満たせばOK
for i in li:
    if n <= m//i:
        print(i)
        break

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)

import sys
import math
from collections import deque

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


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


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


def __starting_point():
    main()
__starting_point()

import bisect
def enum_devisors(n):
    divisors = set([])
    for i in range(1, int(n**.5) + 1):
        if n%i == 0:
            divisors.add(i)
            divisors.add(n//i)
    return divisors

n,m = list(map(int, input().split()))
devisors = sorted(enum_devisors(m))
d = devisors[bisect.bisect_left(devisors, n)]
print(m//d)

N,M=map(int, input().split())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
A=make_divisors(M)
for i in range(len(A)):
  if A[i]>=N:
    print(A[-1-i])
    return

import math

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

main()

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

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
n,m=map(int, input().split())
ans=0
for i in make_divisors(m):
  if m//i>=n:
    ans=i
print(ans)

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

# 約数列挙
def enum_div(N):
    ret = []
    i = 1
    while True:
        if i**2 > N:
            break
        if N % i == 0:
            ret.append(i)
            if i**2 != N:
                ret.append(N / i)
        i += 1
    return ret

ans = 0
for i in enum_div(M):
    if i >= N:
        ans = max(ans,M / i)

print(int(ans))

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

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

    print(ans)
    return


def __starting_point():
    main()

__starting_point()

# author:  Taichicchi
# created: 11.10.2020 20:56:53

import sys


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


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

i = 1
ans = 1
d_ls = make_divisors(M)
for i in d_ls:
    if i * N > M:
        break

    if (M - N * i) % i == 0:
        ans = i
    i += 1

print(ans)


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

while gcd*N!=M:
  gcd = M//N
  N = 1+(M-1)//gcd

print(gcd)

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

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

l = make_divisors(m)

l.reverse()


for x in l:
    if m // x >= n:
        print(x)
        break


# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque

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


# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, M):
    div = divisor(M)
    div.sort()
    ans = 0
    for d in div:
        if M // d >= N:
            ans = d
    print(ans)


def __starting_point():
    # S = input()
    # N = int(input())
    N, M = list(map(int, input().split()))
    # A = [int(i) for i in input().split()]
    # B = [int(i) for i in input().split()]
    # AB = [[int(i) for i in input().split()] for _ in range(N)]
    solve(N, M)

    # # test
    # from random import randint
    # from func import random_str
    # solve()

__starting_point()

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

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())
h = m // n
ans = 0

for d in make_divisors(m):
    if d <= h:
        ans = max(ans, d)

print(ans)

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

# 約数列挙
def enum_div(N):
    ret = []
    for i in range(1,int(N**0.5)+1):
        if N % i == 0:
            ret.append(i)
            if i**2 != N:
                ret.append(N // i)
        i += 1
    return ret

ans = 0
for i in enum_div(M):
    if i >= N:
        ans = max(ans,M // i)

print(int(ans))

from math import sqrt

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

n, m = map(int, input().split())
for i in f(m):
    if n <= i:
        print(m//i)
        return

n,m=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)

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
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
dic = yaku(m)
ans = 1
for k in dic:
    if k*n <= m:
        ans = max(ans,k)
print(ans)


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)

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

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

ans=[]

for i in a:
  if m//i>=n:
    ans.append(i)
    
print(max(ans))

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

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

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

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

print(([i for i in divisors if i <= m/n][-1]))


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

print(ans)


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



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

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

    div = make_divisors(M)
    for d in div:
        if d <= M // N:
            print(d)
            break


def __starting_point():
    resolve()

__starting_point()

import sys
input = sys.stdin.readline


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


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


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


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

__starting_point()


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

    print(ans)


def __starting_point():
    resolve()
__starting_point()

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


N, M = list(map(int, input().split()))
divs = sorted(enum_divisors(M), reverse=True)
ans = max(d for d in divs if M // d >= N)
print(ans)


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

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

print(([i for i in divisors if i <= m/n][-1]))


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

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n%i == 0:
      divisors.append(i)
      if i != n//i:
        divisors.append(n//i)
  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

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


k, s = list(map(int, input().split()))

p = s
factors = {}

while p > 1:
    f = False
    for i in range(2, int(p**0.5)+1):
        if p % i == 0:
            if i in factors:
                factors[i] += 1
            else:
                factors[i] = 1

            p //= i
            f = True
            break

    if not f:
        if p in factors:
            factors[p] += 1
        else:
            factors[p] = 1
        break

if len(factors) == 0:
    print(1)
else:
    primes = list(factors.keys())
    exp = [0] * len(primes)
    upper = s/k
    ans = 1

    while exp[0] <= factors[primes[0]]:
        num = 1
        for i in range(len(primes)):
            num *= pow(primes[i], exp[i])

        if num == upper:
            ans = num
            break
        elif num < upper:
            ans = max(ans, num)

        index = len(primes)-1
        done = False
        while not done:
            exp[index] += 1
            if exp[index] > factors[primes[index]]:
                if index == 0:
                    break
                else:
                    exp[index] = 0
                    index -= 1
            else:
                done = True

    print(ans)

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

import sys
import math

N, M = map(int, sys.stdin.readline().split())

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

print(ans)

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

def __starting_point():
    main()
__starting_point()

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

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

y = make_divisors(m)

res = 1

for i in y:
    if i <=x:
        res = i
        
print(res)

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)