import std; void main(){ auto a = readln.split.to!(ulong[]); ulong n = a[0]; ulong p = a[1]; ulong r = 0; for(;p <= n; p *= a[1]){ r += n / p; } writeln(a[1].powmod(r, 998244353UL)); }