# 難しく考えすぎたらしい # 全探索すればいい # N<10**5と小さい # 素因数分解はdefaultdict型に改造した # 辞書型に改造した from collections import defaultdict def factorization(n): arr = defaultdict(int) temp = n 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[i] = cnt if temp!=1: arr[temp] = 1 #if arr==[]: #素因数として1が加えられないようにした # arr.append([n, 1]) return arr N, K = map(int, input().split()) N_factors = factorization(N) candidates = [] for i in range(1, N): i_factors = factorization(i) common = 0 for d in N_factors: common += min(N_factors[d], i_factors[d]) if common >= K: div_count = 1 for di in i_factors: div_count *= (i_factors[di]+1) candidates.append([div_count, i]) candidates.sort(key = lambda x:(-x[0], x[1])) print(candidates[0][1]) #print(candidates)