#include using namespace std; #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep1(i, n) for (ll i = 1; i <= (n); ++i) #define rrep(i, n) for (ll i = n; i > 0; --i) #define bitrep(i, n) for (ll i = 0; i < (1 << n); ++i) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define yesNo(b) ((b) ? "Yes" : "No") using ll = long long; using ull = unsigned long long; using ld = long double; string alphabet = "abcdefghijklmnopqrstuvwxyz"; string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const double pi = 3.141592653589793; ll smallMOD = 998244353; ll bigMOD = 1000000007; int dx[] = {1, 0, -1, 0, 1, -1, -1, 1}; int dy[] = {0, 1, 0, -1, 1, 1, -1, -1}; ll h, w; vector mp; ll ans = 0; // 0,0からh-1,w-1までをdfs. ll dfs(ll x, ll y, ll jewel) { ll res = 0; rep(i, 2) { ll nx = x + dx[i]; ll ny = y + dy[i]; if (nx < 0 || nx >= h || ny < 0 || ny >= w) { continue; } if (mp[nx][ny] == '#') continue; if (mp[nx][ny] == 'o') { res += dfs(nx, ny, jewel + 1); } if (mp[nx][ny] == 'x') { if (jewel >= 1) res += dfs(nx, ny, jewel - 1); else continue; } } if (x == h - 1 && y == w - 1) { if (jewel >= 0) return 1; else return 0; } return res; } int main() { cin >> h >> w; mp.resize(h); rep(i, h) cin >> mp[i]; // #は通れない、oはjewelが増える、xはjewelが減る // #を通らず、jewelが0未満にならないような経路数を求める // DFSで探索する cout << dfs(0, 0, 1) << endl; return 0; }