#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; struct Eratosthenes { vector isprime; vector primes; vector spf; // smallest prime factors vector mobius; Eratosthenes(int N) : isprime(N + 1, true), spf(N + 1, -1), mobius(N + 1, 1) { isprime[1] = false; spf[1] = 1; for(int p = 2; p <= N; p++){ if(!isprime[p]) continue; primes.push_back(p); spf[p] = p; mobius[p] = -1; for(int q = p * 2; q <= N; q += p){ isprime[q] = false; if(spf[q] == -1) spf[q] = p; mobius[q] = ((q / p) % p == 0 ? 0 : -mobius[q]); } } } vector> factorize(int n) { vector> res; while(n > 1) { int p = spf[n], e = 0; while(spf[n] == p) n /= p, e++; res.push_back({p, e}); // p^e } return res; } vector divisors(int n) { vector res({1}); auto pf = factorize(n); for(auto p : pf) { int s = (int)res.size(); for(int i = 0; i < s; i++) { int v = 1; for(int j = 0; j < p.second; j++) { v *= p.first; res.push_back(res[i] * v); } } } return res; } template void fast_zeta(vector< T > &f) { int N = f.size(); vector isprime = Eratosthenes(N); for(int p = 2; p < N; p++) { if(!isprime[p]) continue; for(int k = (N - 1) / p; k >= 1; k--) { f[k] += f[k * p]; } } } template void fast_mobius(vector< T > &F) { int N = F.size(); vector isprime = Eratosthenes(N); for(int p = 2; p < N; p++) { if(!isprime[p]) continue; for(int k = 1; k * p < N; k++) { F[k] -= F[k * p]; } } } template vector< T > gcd_convolution(const vector< T > &f, const vector< T > &g) { int N = max(f.size(), g.size()); vector< T > F(N, 0), G(N, 0), H(N); for(int i = 0; i < f.size(); i++) F[i] = f[i]; for(int i = 0; i < g.size(); i++) G[i] = g[i]; fast_zeta(F); fast_zeta(G); for(int i = 1; i < N; i++) H[i] = F[i] * G[i]; fast_mobius(H); return H; } long long fast_euler_phi(int n) { auto pf = factorize(n); long long res = n; for(auto p : pf) { res *= p.first - 1; res /= p.first; } return res; } }; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N,K; cin >> N >> K; Eratosthenes sieve(N); auto pf_N = sieve.factorize(N); vector target(N + 1, 0); int M = -1, dM = 0; for(auto [p, e] : pf_N) target[p] = e; for(int i = 1; i < N; i++) { auto pf_i = sieve.factorize(i); int cnt = 0, di = 1; for(auto [p, e] : pf_i) { cnt += min(target[p], e); di *= e + 1; } if(cnt >= K && dM < di) { M = i; dM = di; } } cout << M << endl; }