#line 1 "e.cpp" #include using namespace std; using ll=long long; const ll ILL=2167167167167167167; const int INF=2100000000; #define rep(i,a,b) for (int i=(int)(a);i<(int)(b);i++) #define all(p) p.begin(),p.end() template using pq_ = priority_queue, greater>; template int LB(vector &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();} template int UB(vector &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();} template bool chmin(T &a,T b){if(b bool chmax(T &a,T b){if(a void So(vector &v) {sort(v.begin(),v.end());} template void Sore(vector &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});} bool yneos(bool a,bool upp=false){if(a){cout<<(upp?"YES\n":"Yes\n");}else{cout<<(upp?"NO\n":"No\n");}return a;} template void vec_out(vector &p,int ty=0){ if(ty==2){cout<<'{';for(int i=0;i<(int)p.size();i++){if(i){cout<<",";}cout<<'"'< T vec_min(vector &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmin(ans,x);return ans;} template T vec_max(vector &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmax(ans,x);return ans;} template T vec_sum(vector &a){T ans=T(0);for(auto &x:a) ans+=x;return ans;} int pop_count(long long a){int res=0;while(a){res+=(int)(a&1),a>>=1;}return res;} template T square(T a){return a * a;} //Nの正の約数を列挙する vector Divisors(long long N){ vector p,q; long long i=1,K=0; while(i*i=0;i--){ p.push_back(q[i]); } return p; } #line 4 "/Users/Shared/po167_library/ds/Doubling.hpp" namespace po167{ template struct Doubling_op{ struct result{ long long times; int ind; T val; }; int n; int depth; std::vector> index; std::vector> val; Doubling_op(std::vector p, std::vector v, long long lim = (1ll << 60) - 1){ n = p.size(); for (auto x : p) assert(0 <= x && x < n); assert(n == (int)v.size()); depth = 1; while ((1ll << depth) <= lim) depth++; index.resize(depth); val.resize(depth); index[0] = p; val[0] = v; for (int i = 1; i < depth; i++){ index[i].resize(n); val[i].resize(n); for (int j = 0; j < n; j++){ int tmp = index[i - 1][j]; index[i][j] = index[i - 1][tmp]; val[i][j] = op(val[i - 1][j], val[i - 1][tmp]); } } } result query(int start_ind, T start_val, long long times){ assert(0 <= start_ind && start_ind < n); assert(0 <= times && times < (1ll << depth)); int i = 0; long long TIMES = times; while (times){ if (times & 1){ start_val = op(start_val, val[i][start_ind]); start_ind = index[i][start_ind]; } i++; times >>= 1; } return {TIMES, start_ind, start_val}; } result max_right(int start_ind, T start_val, auto f){ if (!f(start_val)) return {-1, start_ind, start_val}; long long times = 0; for (int d = depth - 1; d >= 0; d--){ if (f(op(start_val, val[d][start_ind]))){ start_val = op(start_val, val[d][start_ind]); start_ind = index[d][start_ind]; times += (1ll << d); } } return {times, start_ind, start_val}; } }; struct Doubling{ int n; int depth; std::vector> index; Doubling(std::vector p, long long lim = (1ll << 60) - 1){ n = p.size(); for (auto x : p) assert(0 <= x && x < n); depth = 1; while ((1ll << depth) <= lim) depth++; index.resize(depth); index[0] = p; for (int i = 1; i < depth; i++){ index[i].resize(n); for (int j = 0; j < n; j++){ index[i][j] = index[i - 1][index[i - 1][j]]; } } } int query(int ind, long long times){ assert(0 <= ind && ind < n); assert(0 <= times && times < (1ll << depth)); int i = 0; while (times){ if (times & 1) ind = index[i][ind]; i++; times >>= 1; } return ind; } }; } #line 46 "e.cpp" void solve(); // DEAR MYSTERIES / TOMOO int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t = 1; // cin >> t; rep(i, 0, t) solve(); } void solve(){ const int P = 100'003; vector to(P); rep(i, 1, P) { for (int j = i; j < P; j += i) { to[j] = (to[j] + i) % P; } } po167::Doubling D(to); ll N, K; cin >> N >> K; auto tmp = Divisors(N); ll st = vec_sum(tmp) % P; if (K == 1) { cout << N << "\n"; } else { cout << D.query(st, K - 2) << "\n"; } }