import sys input = sys.stdin.readline from collections import * N, M = map(int, input().split()) bit = [] for i in range(35): bit.append((N>>i)&1) ans = 0 MOD = 998244353 if len(bit)<=M: lx = 0 for i in range(len(bit)-1): lx ^= bit[i] ans += lx*pow(2, i, MOD) ans %= MOD rx = 0 for i in range(len(bit)+M-2, M-1, -1): rx ^= bit[i-M+1] ans += rx*pow(2, i, MOD) ans %= MOD ans += lx*pow(2, len(bit)-1, MOD)*(pow(2, M-len(bit)+1, MOD)-1)%MOD ans %= MOD else: for i in range(M): ans ^= N*pow(2, i, MOD) ans %= MOD print(ans)