from collections import Counter from math import gcd def factorize(n): p = 2 while p * p <= n: while n % p == 0: yield p n //= p p += 1 if n > 1: yield n def number_of_divisors(n: int) -> int: res = 1 for k, v in Counter(factorize(n)).items(): res *= v+1 return res N, K = map(int, input().split()) dmax = 0 ans = 0 for i in range(1, N): g = gcd(i, N) np = len(list(factorize(g))) if np >= K: nd = number_of_divisors(i) if dmax < nd: dmax = nd ans = i print(ans)