#include <bits/stdc++.h>
typedef long long ll ;
#define int ll
#define ME(x , y) memset(x , y , sizeof(x))
using namespace std ;
typedef pair<int,int> pii;
int quickpow(int a,int b,int mo){int s;for(s=1;b;b>>= 1,a=a*a%mo)if(b&1)s=s*a%mo;return s;}
#define INF 0x3f3f3f3f
const double PI = acos(-1.0);
const int maxn = 14;
const int N = 3e4+9;
const int mod = 998244353;
map<int,int>vis;
struct node{
int a[maxn][maxn];
node(){memset(a , 0 , sizeof(a));}
node operator * (const node B)const{
node C ;
for(int i = 0 ; i < maxn ; i++){
for(int j = 0 ; j < maxn ; j++){
for(int k = 0 ; k < maxn ; k++){
C.a[i][j] = (C.a[i][j] + (a[i][k] % mod * B.a[k][j] % mod) % mod) % mod;
}
}
}
return C;
}
};
node qpow(node a , int b){
node c ;
for(int i = 0 ; i < maxn ; i++){
c.a[i][i] = 1 ;
}
while(b){
if(b&1){
c = c * a ;
}
b >>= 1 ;
a = a * a ;
}
return c;
}
int a[maxn][maxn] ={
{0,0,1,0,0,0,0,0,0,0,0,0,0,0},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,1,0,1,0,0,0,0,0,0,0,0,0,0},
{0,0,1,1,0,0,0,0,0,0,0,0,0,0},
{0,0,1,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,1,0,0,0,0,0,0,0,0,0},//6
{0,0,0,0,0,0,0,0,0,0,0,1,0,0},
{0,0,0,0,0,0,0,0,0,0,1,0,0,0},
{0,0,0,0,0,1,0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,0,1,0,0,0,0,0,0},//10
{0,0,0,0,0,0,1,0,0,0,0,0,0,0},
{0,0,0,1,0,0,0,0,0,0,0,0,0,1},
{0,0,0,0,0,0,0,0,1,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,1,0,0,0,0},
};
map<string,int>cnt;
void Solve(){
cnt["1"] = 0 ;cnt["2"] = 1 ;
cnt["4"] = 2 ;cnt["6"] = 3 ;
cnt["16"] = 4 ;cnt["26"] = 5 ;
cnt["41"] = 6 ;cnt["44"] = 7 ;
cnt["46"] = 8 ;cnt["61"] = 9 ;
cnt["62"] = 10 ;cnt["64"] = 11 ;
cnt["66"] = 12 ;cnt["42"] = 13 ;
node A , B , C;
for(int i = 0 ; i < 14 ; i++){
for(int j = 0 ; j < 14 ; j++){
A.a[i][j] = a[i][j];
}
}
B.a[0][0] = 1 ;
int n; string s;
cin >> n >> s;
C = qpow(A , n) * B ;
cout << C.a[cnt[s]][0] << endl;
}
signed main(){
#ifdef ONLINE_JUDGE
#else
freopen("D:\\c++\\in.txt", "r", stdin);
//freopen("D:\\c++\\out.txt", "w", stdout);
#endif
Solve();
}