/* -*- coding: utf-8 -*- * * 2380.cc: No.2380 Sylow P-subgroup - yukicoder */ #include #include using namespace std; /* constant */ const int MOD = 998244353; /* typedef */ typedef long long ll; /* global variables */ /* subroutines */ int powmod(int a, ll b) { int p = 1; while (b > 0) { if (b & 1) p = (ll)p * a % MOD; a = (ll)a * a % MOD; b >>= 1; } return p; } /* main */ int main() { ll n; int p; scanf("%lld%d", &n, &p); ll e = 0; while (n > 0) { n /= p; e += n; } printf("%d\n", powmod(p, e)); return 0; }