// #pragma GCC target("avx2") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") #include #include #include #include #include #include #include #include #include #include #include #include #include #define _USE_MATH_DEFINES #include using namespace std; using lg = long long; using pii = pair; using pll = pair; #define TEST cerr << "TEST" << endl #define IINF 2147483647 #define LLINF 9223372036854775807LL #define AMARI 998244353 // #define AMARI 1000000007 #define TEMOTO ((sizeof(long double) == 16) ? false : true) #define TIME_LIMIT 1980 * (TEMOTO ? 1 : 1000) #define el '\n' #define El '\n' lg bekizyou(lg a,lg b){ lg ans = 1,temp = a; while(b){ if(b % 2){ ans *= temp; ans %= AMARI; } temp *= temp; temp %= AMARI; b /= 2; } return ans; } #define MULTI_TEST_CASE false void solve(void) { lg n,p; cin >> n >> p; //n!がpで何回割れるかっぽい? lg ans = 0; int cnt = 0; for(lg i = p; i <= n; i *= p){ cnt++; lg temp = n / i; temp %= AMARI; ans += temp; if(ans > AMARI)ans -= AMARI; //cerr << ans << el; } cout << bekizyou(p,ans) << el; return; } void calc(void) { return; } int main(void) { cin.tie(nullptr); ios::sync_with_stdio(false); calc(); int t = 1; if (MULTI_TEST_CASE) cin >> t; while (t--) { solve(); } return 0; }