#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define M_PI 3.14159265358979323846 using namespace std; //conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } inline int readInt() { int x; scanf("%d", &x); return x; } //typedef //------------------------------------------ typedef vector VI; typedef vector VVI; typedef vector VS; typedef pair PII; typedef pair TIII; typedef long long LL; typedef unsigned long long ULL; typedef vector VLL; typedef vector VVLL; //container util //------------------------------------------ #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) #define SQ(a) ((a)*(a)) #define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort((c).begin(),(c).end()) //repetition //------------------------------------------ #define FOR(i,s,n) for(int i=s;i<(int)n;++i) #define REP(i,n) FOR(i,0,n) #define MOD 1000000007 #define rep(i, a, b) for(int i = a; i < (b); ++i) #define trav(a, x) for(auto& a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() struct Edge { int to, cost; Edge(int to, int cost): to(to), cost(cost) {} }; typedef long long ll; typedef pair pii; typedef vector vi; typedef vector> AdjList; AdjList graph; const int INF = 100000000; LL N, M; map prime; int main() { //cout << fixed << setprecision(15); int N, K; cin >> N >> K; int n = N; vector v; for(int i=2; i<=N; ++i){ while(N%i == 0){ v.push_back(i); prime[i]++; N /= i; } } if(N != 1) { v.push_back(N); prime[N]++; } LL t = 1; int idx=0; for(auto e: prime){ if(idx>=K-1) break; for(int i=0; i=K-1) break; t *= e.first; idx++; } } vector v2; for(int i=n-1; i>=1; --i) if(i%t == 0) v2.push_back(i); int ans = 0; LL num = 0; for(int i=0; i mp; for(int j=2; j<=t; ++j){ while(t%j==0){ mp[j]++; t/=j; } } t = 1; for(auto e: mp){ t *= (e.second+1); } if(num < t){ num = t; ans = v2[i]; }else if(num == t){ if(ans > v2[i]) { ans = v2[i]; } } } cout << ans << endl; return 0; }