N, P = gets.split.map(&:to_i) MOD = 998_244_353 e = 0 x = P while x <= N e += N / x x *= P end puts P.pow(e, MOD)