#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int H, W; cin >> H >> W; vector A(H); rep(i, H) cin >> A[i]; vector dh = {1, 0}; vector dw = {0, 1}; int path = 0; auto dfs = [&](auto dfs, int h, int w, int jewl) { if (A[h][w] == 'o') jewl++; if (A[h][w] == 'x') jewl--; if (jewl < 0) return; if (h == H-1 && w == W-1) { path++; return; } rep(i, 2) { int hNew = h + dh[i]; int wNew = w + dw[i]; if (hNew >= H || wNew >= W) continue; if (A[hNew][wNew] == '#') continue; dfs(dfs, hNew, wNew, jewl); } return; }; dfs(dfs, 0, 0, 0); cout << path << endl; return 0; }