#include #include using namespace std; using namespace atcoder; using mint = modint998244353; int main() { int N, M, K = 30; cin >> N >> M; vector> dp(N, vector(K)), binom(K, vector(K, 1)); vector>> ddp(K, vector>(K, vector(2))); if( ((M>>(K-1))&1) == 0 ) { ddp[K-1][0][1] = 1; }else { ddp[K-1][0][0] = 1; ddp[K-1][1][1] = 1; } for( int i = K-2; i >= 0; i-- ) { int D = (M>>i)&1; for( int j = 0; j < K; j++ ) { for( int k = 0; k < 2; k++ ) { for( int d = 0; d < 2; d++ ) { if( j-d < 0 || ( k == 1 && d > D ) ) continue; int k2 = ( d == D ); ddp[i][j][k&k2] += ddp[i+1][j-d][k]; } } } } for( int n = 0; n < K; n++ ) { for( int r = 0; r <= n; r++ ) { for( int k = 1; k <= n; k++ ) binom[n][r] *= k; for( int k = 1; k <= r; k++ ) binom[n][r] /= k; for( int k = 1; k <= n-r; k++ ) binom[n][r] /= k; } } for( int j = 0; j < K; j++ ) { dp[0][j] = ddp[0][j][0]+ddp[0][j][1]; } for( int i = 0; i < N-1; i++ ) { for( int j = 0; j < K; j++ ) { for( int k = 0; k <= j; k++ ) { dp[i+1][k] += dp[i][j]*binom[j][k]; } } } mint ans = 0; for( int j = 0; j < K; j++ ) { ans += dp[N-1][j]; } cout << ans.val() << endl; }