#include using namespace std; #include using mint = atcoder::modint998244353; #define int long long signed main() { int h,w; cin >> h >> w; vector s(h); for(int i = 0; i < h; i++) cin >> s[i]; vector>> dp(h,vector>(w,vector(h*w+1,0))); dp[0][0][1]++; deque> q; q.push_back({0,0}); vector> v(h,vector(w,false)); vector> z = v; z[0][0] = true; while(q.size() > 0) { int x,y; tie(x,y) = q.front(); v[x][y] = true; q.pop_front(); if(x != h-1 && !v[x+1][y] && s[x+1][y] != '#') { int t = 1; if(s[x+1][y] == 'x') t-=2; for(int i = 0; i <= h*w; i++) { if(i+t >= 0 && i+t <= h*w) dp[x+1][y][i+t]+=dp[x][y][i]; } if(!z[x+1][y]) q.push_back({x+1,y}); z[x+1][y] = true; } if(y != w-1 && !v[x][y+1] && s[x][y+1] != '#') { int t = 1; if(s[x][y+1] == 'x') t-=2; for(int i = 0; i <= h*w; i++) { if(i+t >= 0 && i+t <= h*w) dp[x][y+1][i+t]+=dp[x][y][i]; } if(!z[x][y+1]) q.push_back({x,y+1}); z[x][y+1] = true; } } int ans = 0; for(int i = 1; i <= h*w; i++) ans+=dp[h-1][w-1][i]; cout << ans << endl; }