#ifndef CLASS_MODINT #define CLASS_MODINT #include template class modint { private: std::uint32_t n; public: modint() : n(0) {}; modint(std::int64_t n_) : n((n_ >= 0 ? n_ : mod - (-n_) % mod) % mod) {}; static constexpr std::uint32_t get_mod() { return mod; } std::uint32_t get() const { return n; } bool operator==(const modint& m) const { return n == m.n; } bool operator!=(const modint& m) const { return n != m.n; } modint& operator+=(const modint& m) { n += m.n; n = (n < mod ? n : n - mod); return *this; } modint& operator-=(const modint& m) { n += mod - m.n; n = (n < mod ? n : n - mod); return *this; } modint& operator*=(const modint& m) { n = std::uint64_t(n) * m.n % mod; return *this; } modint operator+(const modint& m) const { return modint(*this) += m; } modint operator-(const modint& m) const { return modint(*this) -= m; } modint operator*(const modint& m) const { return modint(*this) *= m; } modint inv() const { return (*this).pow(mod - 2); } modint pow(std::uint64_t b) const { modint ans = 1, m = modint(*this); while (b) { if (b & 1) ans *= m; m *= m; b >>= 1; } return ans; } }; #endif // CLASS_MODINT #include #include using namespace std; using mint = modint<998244353>; int main() { int N, M; cin >> N >> M; const int bits = 30; vector > comb(bits + 1); for (int i = 0; i <= bits; i++) { comb[i].resize(i + 1); comb[i][0] = 1; for (int j = 1; j <= i; j++) { comb[i][j] = comb[i - 1][j - 1] + (j != i ? comb[i - 1][j] : 0); } } vector > dp(N + 1, vector(bits + 1)); dp[0][0] = 1; for (int i = 1; i <= N; i++) { for (int j = 0; j <= bits; j++) { for (int k = 0; k <= j; k++) { dp[i][j] += dp[i - 1][k] * comb[j][k]; } } } vector hist(bits + 1, 0); int pops = 0; for (int i = bits - 1; i >= 0; i--) { if (((M >> i) & 1) == 1) { for (int j = 0; j <= i; j++) { hist[pops + j] += comb[i][j]; } pops += 1; } } hist[pops] += 1; mint answer = 0; for (int i = 0; i <= bits; i++) { answer += dp[N][i] * hist[i]; } cout << answer.get() << endl; return 0; }