#include // #include using namespace std; // using namespace atcoder; // using mint = modint998244353; //using mint = modint1000000007; using ll = long long; using P = pair; using T = tuple; templatebool chmax(T_& a, const T_& b) { if (a < b) { a = b;return true; } else { return false; } } templatebool chmin(T_& a, const T_& b) { if (a > b) { a = b;return true; } else { return false; } } #ifdef LOCAL template ostream& operator<<(ostream& o, const pair& p) { return o << "(" << p.first << ", " << p.second << ")"; } template ostream& operator<<(ostream& o, const tuple& t) { o << "("; apply([&o](auto&&... a) { int c = 0; (((o << (c++ ? ", " : "") << a)), ...); }, t); return o << ")"; } template auto operator<<(ostream& o, const V& v) -> std::enable_if_t && !std::is_same_v, decltype(v.begin(), o)> { o << "{"; int c = 0; for (auto& x : v) o << (c++ ? ", " : "") << x; return o << "}"; } #define dbg(...) cerr<<"["<<#__VA_ARGS__<<"]: ",([](auto&&... a){((cerr< isprime; // 整数 i を割り切る最小の素数 vector minfactor; // コンストラクタで篩を回す Eratosthenes(int N) : isprime(N + 1, true), minfactor(N + 1, -1) { // 1 は予めふるい落としておく isprime[1] = false; minfactor[1] = 1; // 篩 for (int p = 2; p <= N; ++p) { // すでに合成数であるものはスキップする if (!isprime[p]) continue; // p についての情報更新 minfactor[p] = p; // p 以外の p の倍数から素数ラベルを剥奪 for (int q = p * 2; q <= N; q += p) { // q は合成数なのでふるい落とす isprime[q] = false; // q は p で割り切れる旨を更新 if (minfactor[q] == -1) minfactor[q] = p; } } } // 高速素因数分解 // pair (素因子, 指数) の vector を返す vector> factorize(int n) { vector> res; while (n > 1) { int p = minfactor[n]; int exp = 0; // n で割り切れる限り割る while (minfactor[n] == p) { n /= p; ++exp; } res.emplace_back(p, exp); } return res; } // 高速約数列挙 vector divisors(int n) { vector res({ 1 }); // n を素因数分解 (メンバ関数使用) 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; } }; int main() { // エラトステネスの篩 Eratosthenes er(100003); ll n, k; cin >> n >> k; set st; vector ans; ll x = n, t = 0; while (!st.contains(x)) { t++; st.emplace(x); ans.push_back(x); auto pf = er.divisors(x); ll cnt = 0; for (int i = 0; i < (int)pf.size(); ++i) { cnt += pf[i]; } x = cnt % 100003; } k--; dbg(k, t); cout << ans[k % t] << "\n"; }