N,K = map(int, input().split()) P = 998244353 inv6 = pow(6, P-2, P) def merge(LIST1, LIST2): ans = [0,0,0,0,0,0] for i in range(6): for j in range(6): ans[(i+j)%6] += LIST1[i] * LIST2[j] return [a%P for a in ans] memo = [inv6 for _ in range(6)] if N%2 == 1: ans = memo[:] else: ans = None N >>= 1 while N > 0: memo = merge(memo, memo) if N%2 == 1: if ans is None: ans = memo[:] else: ans = merge(ans, memo) N >>= 1 print(memo[K]%P)