MOD = 998244353 N, M = map(int, input().split()) n = N NB = [] while n > 0: NB.append(n & 1) n >>= 1 x = len(NB) if x > M: # 計算量が大きくならない理由 # x <= 30、 x >= M #  よって y < 60 なので下のfor文を回しても問題ない y = x + M - 1 ans = 0 b = 1 for i in range(y): start = max(0, i - M + 1) end = min(i, x) + 1 a = sum(NB[start:end]) & 1 ans += a * b ans %= MOD #print(i,a,b,a*b) b <<= 1 else: # x-1桁目まで ans = 0 b = 1 for i in range(x-1): start = 0 end = i + 1 a = sum(NB[start:end]) & 1 ans += a * b b <<= 1 # x桁目~ M桁目まで ans += (sum(NB) & 1) * (pow(2, M - x+1, MOD)-1) * pow(2, x-1, MOD) % MOD # M+1桁 ~ x+M+1桁目まで b = pow(2,M,MOD) for i in range(x - 1): start = i + 1 end = x + 1 a = sum(NB[start:end]) & 1 ans += a * b ans %= MOD b <<= 1 print(ans)