#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
using std::cout;
using std::cin;
using std::string;
using std::vector;
using std::endl;

int main()
{
    const long long mod = 998244353;
    int h, w;
    cin >> h >> w;
    vector<string> graph(h);
    for (int i = 0; i < h; i++) {
        cin >> graph[i];
    }
    long long ans = 1;
    int groups = 0;
    for (int i = 0; i < h; i++) {
        if (ans == 0) break;
        int y = i;
        int x = 0;
        char diag = '.';
        while (y >= 0 && x <= w - 1) {
            if (graph[y][x] == 'R') {
                if (diag == 'B') ans = 0;
                else diag = 'R';
            }
            if (graph[y][x] == 'B') {
                if (diag == 'R') ans = 0;
                else diag = 'B';
            }
            y--;
            x++;
        }
        if (diag == '.') {
            groups++;
        }
    }
    for (int i = 1; i < w; i++) {
        if (ans == 0) break;
        int y = h - 1;
        int x = i;
        char diag = '.';
        while (y >= 0 && x <= w - 1) {
            if (graph[y][x] == 'R') {
                if (diag == 'B') ans = 0;
                else diag = 'R';
            }
            if (graph[y][x] == 'B') {
                if (diag == 'R') ans = 0;
                else diag = 'B';
            }
            y--;
            x++;
        }
        if (diag == '.') {
            groups++;
        }
    }
    if (ans != 0) {
        for (int i = 0; i < groups; i++) {
            ans = ans * 2 % mod;
        }
    }
    cout << ans;
    return 0;
}
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
//gouravrj code:P
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF  0x3f3f3f3f3f3f3f3fLL

typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;

const int mod = 1000000007;
const int N = 3e5, M = N;
/*******************************************************************************************/
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for (int i = 0; i < v.size(); ++i) {if (i) os << ", "; os << v[i]; }
    os << "]\n"; return os;
}
template <typename T> ostream& operator<<(ostream& os, const set<T>& v) {
    os << "{"; for (auto it : v) { os << it; if (it != *v.rbegin()) os << ", "; } os << "}\n";
    return os;
}
template <typename T> ostream& operator<<(ostream& os, const multiset<T>& v) {
    os << "{"; for (auto it : v) { os << it; if (it != *v.rbegin()) os << ", "; } os << "}\n";
    return os;
}
template <typename T, typename S> ostream& operator<<(ostream& os, const map<T, S>& v) {
    os << "{"; for (auto it : v) { os << "(" << it.first << " : " << it.second << ")"; if (it != *v.rbegin()) os << ", "; } os << "}\n"; return os;
}
template <typename T, typename S> ostream& operator<<(ostream& os, const unordered_map<T, S>& v) {
    os << "{"; for (auto it : v) { os << "(" << it.first << " : " << it.second << ")"; os << ", "; } os << "}\n";
    return os;
}
template <typename T, typename S> ostream& operator<<(ostream& os, const pair<T, S>& v) {
    os << "("; os << v.first << ", " << v.second << ")";
    return os;
}
template <typename T> inline istream &operator>>(istream &in, vector<T> &a) {
    for (auto &x : a) in >> x;
    return in;
}
#ifndef ONLINE_JUDGE
    const string COLOR_RESET = "\033[0m", BRIGHT_GREEN = "\033[1;32m", BRIGHT_RED = "\033[0;31m", BRIGHT_CYAN = "\033[1;36m";
    vector<string> tokenizer(const string args) {
    	string tk = args; vector<string> v;
    	for (int i = 0; i < tk.size(); i++) {
        	string s = ""; int j = i;
       		while (j < tk.size() && tk[j] != ',')s += tk[j++];
        	i = j; v.push_back(s);
    	}
    reverse(all(v));
    	return v;
    }
    void debugg(vector<string> args) { cerr << "\b\b "; }
    template <typename Head, typename... Tail>
    void debugg(vector<string>args, Head H, Tail... T) {
    	if (!sz(args))return ;
    	cerr << " [" << BRIGHT_CYAN << args.back() << ": " << BRIGHT_GREEN << H << COLOR_RESET << "] ";
    	if (sz(args)) {args.pop_back(); debugg(args, T...);}
    }
    #define deb(...) { debugg(tokenizer(#__VA_ARGS__), __VA_ARGS__, __LINE__);cerr<<'\n'; }
#endif
#ifdef ONLINE_JUDGE
    #define deb(...)
#endif

/*******************************************************************************************/

void run_case() {
    ll int t, i, j, k, p,  x, y, u,  n, m, w;
    
    ll A,B;
    cin>>A>>B;
    long double ans=A*(B/(100*1.0));
    cout<<fixed<<setprecision(8)<<ans<<'\n';
   

}//end


/*******************************************************************************************/

int main() {
    cin.tie(0)->sync_with_stdio(0);
#ifndef ONLINE_JUDGE
    //freopen("/home/gourav/input1.txt", "r", stdin); freopen("/home/gourav/output1.txt", "w", stdout);
    //freopen("error.txt", "w", stderr);
#endif
    int t = 1;
    //int T;
    // cin >> t;
    Fo(T, 1, t + 1) {
        // cout<<"Case #"<<T<<": ";
        run_case();
    }
    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
    return 0;
}



