import math def count_prime_factor(N): ret = 0 tmp = N c = N//2 + 1 for n in range(2, c): while tmp % n == 0: tmp = tmp // n ret += 1 if tmp == 1: break if ret: return ret else: return 1 def count_divisor(N): ret = 0 c = N//2 + 1 for i in range(1, c): if N % i == 0: ret += 1 if N != i * i: ret += 1 return ret N, K = map(int, input().split()) max_d = 0 ans = 0 for n in range(1, N): gcd = math.gcd(N, n) if count_prime_factor(gcd) >= K: d = count_divisor(n) if max_d < d: max_d = d ans = n print(ans)