# https://tech.aru-zakki.com/python-pow-matrix/ def matmul(A, B): N = len(A) K = len(A[0]) M = len(B[0]) c = [[0 for _ in range(M)] for _ in range(N)] for i in range(N) : for j in range(K) : for k in range(M) : c[i][k] += A[i][j] * B[j][k] % MOD c[i][k] %= MOD return c def pow_matrix(A, p): n = len(A) # 単位行列 c = [[1 if i == j else 0 for i in range(n)] for j in range(n)] while p > 0 : if p%2 == 1 : c = matmul(c, A) A = matmul(A, A) p //= 2 return c def nPr(n, r, mod): if ( r<0 or r>n ): return 0 return g1[n] * g2[n-r] % mod def nCr(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return (g1[n] * g2[r] % mod) * g2[n-r] % mod import sys input = sys.stdin.readline MOD = 998244353 N, K = map(int, input().split()) g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル fact = [1, 1] for i in range( 2, K + 1 ): g1.append( ( g1[-1] * i ) % MOD ) inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD ) g2.append( (g2[-1] * inverse[-1]) % MOD ) fact.append( (fact[-1] * i) % MOD ) A = [[1 for _ in range(K+2)]] C = [[0 for _ in range(K+2)] for _ in range(K+2)] for i in range(K+1): for j in range(K+1): C[i][j] = nCr(K-j, K-i-j, MOD) C[0][-1] = 1 C[-1][-1] = 1 CC = pow_matrix(C, N-1) ans = matmul(A, CC) print(ans[0][-1])