#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
using ll = long long;
using namespace std;

ll n, x;
ll a[50];
ll v[50];
ll l[50];
ll dp[51];
ll dq[51];
int main() {
	cin >> n >> x;
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 1; i < n; ++i) l[i - 1] = a[i] / a[i - 1] - 1;
	l[n - 1] = 2e18;

	ll s = x;
	for (int i = n - 1; i >= 0; --i) {
		v[i] = s / a[i];
		s %= a[i];
	}
	
	dp[0] = 1;
	for (int i = 0; i < n; ++i) {
		if (v[i] == 0) {
			dp[i + 1] = dp[i] + dq[i];
			dq[i + 1] = dq[i];
		} else {
			dp[i + 1] = dp[i] + (v[i] < l[i]) * dq[i];
			dq[i + 1] = dp[i] + dq[i];
		}
	}
	cout << dp[n] << endl;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__)
#else
#define DEBUG(...) 6
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {for (int i=0, b=0; i<(int)s.size(); i++) if (s[i] == '(' || s[i] == '{') b++; else
if (s[i] == ')' || s[i] == '}') b--; else if (s[i] == ',' && b == 0) {cerr << s.substr(0, i) << " = " << x << " | "; debug(s.substr(s.find_first_not_of(' ', i + 1)), args...); break;}}

template<int MOD>
struct ModInt {
    long long v;
    ModInt(long long _v = 0) {v = (-MOD < _v && _v < MOD) ? _v : _v % MOD; if (v < 0) v += MOD;}
    ModInt& operator += (const ModInt &other) {v += other.v; if (v >= MOD) v -= MOD; return *this;}
    ModInt& operator -= (const ModInt &other) {v -= other.v; if (v < 0) v += MOD; return *this;}
    ModInt& operator *= (const ModInt &other) {v = v * other.v % MOD; return *this;}
    ModInt& operator /= (const ModInt &other) {return *this *= inverse(other);}
    bool operator == (const ModInt &other) const {return v == other.v;}
    bool operator != (const ModInt &other) const {return v != other.v;}
    friend ModInt operator + (ModInt a, const ModInt &b) {return a += b;}
    friend ModInt operator - (ModInt a, const ModInt &b) {return a -= b;}
    friend ModInt operator * (ModInt a, const ModInt &b) {return a *= b;}
    friend ModInt operator / (ModInt a, const ModInt &b) {return a /= b;}
    friend ModInt operator - (const ModInt &a) {return 0 - a;}
    friend ModInt power(ModInt a, long long b) {ModInt ret(1); while (b > 0) {if (b & 1) ret *= a; a *= a; b >>= 1;} return ret;}
    friend ModInt inverse(ModInt a) {return power(a, MOD - 2);}
    friend istream& operator >> (istream &is, ModInt &m) {is >> m.v; m.v = (-MOD < m.v && m.v < MOD) ? m.v : m.v % MOD; if (m.v < 0) m.v += MOD; return is;}
    friend ostream& operator << (ostream &os, const ModInt &m) {return os << m.v;}
};
typedef ModInt<998244353> M;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int h, w;
    cin >> h >> w;
    vector<string> grid(h);
    for (int i=0; i<h; i++)
        cin >> grid[i];

    M ret = 1;
    for (int d=0; d<=h+w-2; d++) {
        int cntR = 0, cntB = 0;
        for (int i=max(d-w+1, 0); i<=min(d, h-1); i++) {
            int j = d - i;
            if (grid[i][j] == 'R') cntR++;
            else if (grid[i][j] == 'B') cntB++;
        }
        if (cntR > 0 && cntB > 0)
            ret = 0;
        else if (cntR == 0 && cntB == 0)
            ret *= 2;
    }
    cout << ret << "\n";

    return 0;
}
