#include "bits/stdc++.h" using namespace std; vector> factors(int x) { vector> ps; for (int i = 2; i * i <= x; i++) { if (x % i) continue; int cnt = 0; while(x % i == 0) { cnt++; x /= i; } ps.push_back({i, cnt}); } if (x > 1) ps.push_back({x, 1}); return ps; } void solve() { int n, k; cin >> n >> k; int ans = 0, maxi = 0; for (int x = 1; x < n; x++) { int g = __gcd(x, n); auto gp = factors(g); int cnt = 0; for (auto p : gp) { cnt += p.second; } if (cnt < k) continue; auto ps = factors(x); int m = 1; for (auto p : ps) { m *= p.second + 1; } if (m > maxi) { maxi = m; ans = x; } } cout << ans << endl; } int main() { solve(); //cout << "yui(*-v・)yui" << endl; return 0; }