import std; void read(T...)(string S, ref T args) { auto buf = S.split; foreach (i, ref arg; args) { arg = buf[i].to!(typeof(arg)); } } void main () { long N; int P; readln.read(N, P); solve(N, P); } void solve (long N, int P) { // よくわからんけど、N!のうち素因数Pがどれだけ入ってるかっていうことちゃうか? const long MOD = 998244353; long count = 0; long prime = P; while (N/prime != 0) { count += N / prime; prime *= P; } writeln(modpow(P, count, MOD)); } long modpow (long a, long x, const long MOD) { assert(0 <= a); assert(0 <= x); if (x == 0) { return 1L % MOD; } if (x == 1) { return a % MOD; } if (x % 2 == 0) { auto res = modpow(a, x/2, MOD); return res*res % MOD; } else { return a*modpow(a, x-1, MOD) % MOD; } assert(0); }