# import sys; input = sys.stdin.buffer.readline # sys.setrecursionlimit(10**7) from collections import defaultdict con = 10 ** 9 + 7; INF = float("inf") def getlist(): return list(map(int, input().split())) def gcd(a, b): while b: a, b = b, a % b return a def isPrimeMR(N): d = N - 1 d = d // (d & -d) # L=[2,3,61] L = [2] for a in L: t = d y = pow(a, t, N) if y == 1: continue while y != N - 1: y = (y * y) % N if y == 1 or t == N - 1: return 0 return 1 def findFactorRho(N): m = 1 << N.bit_length() // 8 for c in range(1, 99): f = lambda x: (x * x + c) % N y, r, q, g = 2, 1, 1, 1 while g == 1: x = y for i in range(r): y = f(y) k = 0 while k < r and g == 1: ys = y for i in range(min(m, r - k)): y = f(y) q = q * abs(x - y) % N g = gcd(q, N) k += m r <<= 1 if g == N: g = 1 while g == 1: ys = f(ys) g = gcd(abs(x - ys), N) if g < N: if isPrimeMR(g): return g elif isPrimeMR(N // g): return N // g return findFactorRho(g) def primeFactor(N): i = 2 ret = defaultdict(int) rhoFlg = 0 while i * i <= N: k = 0 while N % i == 0: N //= i k += 1 if k: ret[i] = k i += 1 + i % 2 if i == 101 and N >= 2 ** 20: while N > 1: if isPrimeMR(N): ret[N], N = 1, 1 else: rhoFlg = 1 j = findFactorRho(N) k = 0 while N % j == 0: N //= j k += 1 ret[j] = k if N > 1: ret[N] = 1 if rhoFlg: ret = {x: ret[x] for x in sorted(ret)} return ret #処理内容 def main(): N, K = getlist() D = primeFactor(N) ans = INF val = 0 for i in range(N - 1, 0, -1): d = primeFactor(i) fac_cnt = 0 for j in d: fac_cnt += min(d[j], D[j]) if fac_cnt >= K: divnum = 1 for j in d: divnum *= d[j] + 1 if divnum >= val: ans = i val = divnum print(ans) if __name__ == '__main__': main()