#include using namespace std; const int LOG = 61; const long long MOD = 998244353; long long f(long long N){ vector> dp(LOG + 1, vector(2, 0)); dp[0][LOG] = 1; for (int i = LOG - 1; i >= 0; i--){ int d = N >> i & 1; if (d == 0){ dp[i][0] += dp[i + 1][0]; dp[i][1] += dp[i + 1][1] * 3; } else { dp[i][0] += dp[i + 1][0] * 2; dp[i][1] += dp[i + 1][0] + dp[i + 1][1] * 3; } dp[i][0] %= MOD; dp[i][1] %= MOD; } return dp[0][1]; } int main(){ long long N, K; cin >> N >> K; cout << (f(N + K + 1) - f(K) + MOD) % MOD; }