#include using namespace std; int p_gcd(int m); int gcd(int m, int n); int root(int n); int main() { int n; int k; int ans; int m = 0; cin >> n >> k; for (int i = 2; i < n; i++) { if (p_gcd(gcd(i, n)) >= k) { int r = root(i); if (r > m) { m = r; ans = i; } } } cout << ans << endl; return 0; } int p_gcd(int m) { int cnt = 0; int i = 2; while (m > 1) { if (m % i == 0) { cnt++; m /= i; } else { i++; } } return cnt; } int gcd(int m, int n) { if (m < n) { int tmp = m; m = n; n = tmp; } int r; while (n) { r = m % n; m = n; n = r; } return m; } int root(int n) { int cnt = 0; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { if (i * i == n ) { cnt += 1; } else { cnt += 2; } } } return cnt; }