#include #include #include using mint = atcoder::modint998244353; std::vector inv(const std::vector &f) { const int n = f.size(); std::vector res { f[0].inv() }; for (int k = 1; k < n; k *= 2) { const int l = std::min(2 * k + 1, n); std::vector g(f.begin(), f.begin() + l); std::vector h = atcoder::convolution(res, res); h.resize(l); g = atcoder::convolution(g, h); res.resize(l); for (int i = 0; i < l; ++i) res[i] = res[i] + res[i] - g[i]; } return res; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n, m; std::cin >> n >> m; std::vector f(n + 1); // Σ[i=1,m] (1-x^i)^(-1) mod x^(n+1) for (int i = 1; i <= m; ++i) for (int j = 0; i * j <= n; ++j) { ++f[i * j]; } // f *= 1 - x for (int i = n - 1; i >= 0; --i) { f[i + 1] -= f[i]; } f[0] += 1 - m; std::cout << (mint(m).pow(n) - inv(f)[n]).val() << std::endl; return 0; }