#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define MT make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)<; using vi = vector; using vll = vector; vector> divisorsAll(int n) { vector> res(n + 1); for (int i = 1; i <= n; ++i) { for (int j = i; j <= n; j += i) { res[j].push_back(i); } } return res; } template map factorize(Val n) { map res; for (Val i = 2; (long long)i*i <= n; ++i) { while (n%i == 0) { n /= i; ++res[i]; } } if (n != 1) ++res[n]; return res; } void solve() { // 約数列挙するだけ int N, K; cin >> N >> K; // (約数の個数, -解候補) pii ans(0, 0); auto D = divisorsAll(N); auto F = factorize(N); for (int i = 1; i < N; ++i) { int n = i; int common = 0; each(p, F) { rep(j, p.second) { if (n%p.first == 0) { common++; n /= p.first; } } } if (common >= K) { smax(ans, pii(sz(D[i]), -i)); } } cout << -ans.second << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); solve(); return 0; }