#include <iostream>
#include <cassert>
#include <map>
#define int long long
using namespace std;
const int P = 998244353;
struct Matrix {
int a[4][4];
Matrix() { memset(a, 0, sizeof a); }
void ini(int x = 1) { for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) a[i][j] = (i == j) * x; }
int* operator[](int x) { return a[x]; }
} I, T;
Matrix operator*(Matrix a, Matrix b) {
Matrix c;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
for (int k = 0; k < 4; k++)
c[i][j] += a[i][k] * b[k][j] % P;
c[i][j] %= P;
}
}
return c;
}
Matrix qpow(Matrix x, int y) {
Matrix ret;
ret.ini();
while (y) {
if (y & 1)
ret = ret * x;
y >>= 1;
x = x * x;
}
return ret;
}
int n, m;
int a[105];
int ans;
bool chk() {
a[0] = a[n], a[n + 1] = a[1];
bool ok = 1;
for (int i = 1; i <= n; i++) ok &= (a[i] + (a[i - 1] & a[i + 1]) == m);
if (ok) {
for (int i = 1; i <= n; i++) cout << a[i] << " ";
cout << "\n";
// for (int i = 1; i <= n; i++) assert((a[i] & a[i - 1] & a[i + 1]) == 0);
}
return ok;
}
void dfs(int x) {
if (x == n + 1) {
ans += chk();
return;
}
for (int i = 0; i <= m; i++) a[x] = i, dfs(x + 1);
}
int ans0;
map<int, int> mp;
int dfss(int x) {
if (mp.count(x))
return mp[x];
if (x & 1)
return mp[x] = dfss(x >> 1) * ans0 % P;
else
return mp[x] = (dfss(x >> 1) + dfss((x >> 1) - 1)) % P;
}
/*
010
011
101
110
*/
signed main() {
cin >> n >> m;
T[1][2] = T[1][3] = T[2][1] = T[3][2] = 1;
I.ini(0); I[0][1] = 1; I = I * qpow(T, n - 2); ans0 += I[0][1] + I[0][3];
// cout << ans0 << "\n";
I.ini(0); I[0][2] = 1; I = I * qpow(T, n - 2); ans0 += I[0][1] + I[0][2];
// cout << ans0 << "\n";
I.ini(0); I[0][3] = 1; I = I * qpow(T, n - 2); ans0 += I[0][0] + I[0][2];
ans0 %= P;
// dfs(1);
// cout << ans << "\n";
// cout << ans0 << "\n";
mp[0] = 1;
cout << dfss(m) << "\n";
return 0;
}