N, K = map(int, input().split()) def gcd(x, y): while y: x, y = y, x % y return x def divisor(n): res = set() i = 1 while i * i <= n: if n % i == 0: res.add(i) res.add(n // i) i += 1 return sorted(res) def factorize(n): if n == 1: return [] res = [] x, y = n, 2 while y * y <= x: while x % y == 0: res.append(y) x //= y y += 1 if x > 1: res.append(x) return res maxdiv = 0 res = 0 for i in range(1, N): g = gcd(N, i) if len(factorize(g)) >= K: d = len(divisor(i)) if maxdiv < d: res = i maxdiv = d print(res)