## https://yukicoder.me/problems/no/1952 MOD = 998244353 def main(): N, M = map(int, input().split()) if N == 0: print(0) return n = N array = [] while n > 0: array.append(n % 2) n //= 2 N0 = len(array) if M > 2 * N0: s = sum(array) if s % 2 == 1: b = pow(2, M - 1, MOD) - 1 b %= MOD c = pow(2, N0, MOD) - 1 c %= MOD answer = (b - c) % MOD else: answer = 0 # ε‰εŠ array1 = [0] * N0 for i in range(N0): for j in range(N0): if i + j < N0: array1[i + j] += array[j] array1[i + j] %= 2 p = 1 ans = 0 for i in range(len(array1)): if array1[i] > 0: ans += p ans %= MOD p *= 2 p %= MOD answer += ans answer %= MOD # 後半 array2 = [0] * N0 for i in range(N0): for j in range(N0): if j - i >= 0: array2[j - i] += array[j] array2[j - i] %= 2 p = pow(2, M - 1, MOD) for i in range(N0): if array2[i] > 0: answer += p answer %= MOD p *= 2 p %= MOD print(answer) else: array1 = [0] * M array1 += [0] * N0 for i in range(M): for j in range(N0): array1[i + j] += array[j] array1[i + j] %= 2 p = 1 ans = 0 for i in range(len(array1)): if array1[i] > 0: ans += p ans %= MOD p *= 2 p %= MOD print(ans) if __name__ == "__main__": main()