#include "bits/stdc++.h" using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) vector> c(10, vector(10)); vector x = {0, 1}; vector y = {1, 0}; int h, w; int ans = 0; void dfs(int i, int j, int cost) { if (i == h - 1 && j == w - 1) { int i1 = i; int j1 = j; if (c[i1][j1] == 'o') { ans++; } else { if (cost != 0) ans++; } } for (int t = 0; t < 2; t++) { int i1 = i + x[t]; int j1 = j + y[t]; if (i1 < 0 || i1 >= h) continue; if (j1 < 0 || j1 >= w) continue; if (c[i1][j1] == '#') continue; else if (c[i1][j1] == 'o') { dfs(i1, j1, cost + 1); } else { if (cost != 0) dfs(i1, j1, cost - 1); } } } signed main() { cin >> h >> w; rep(i, h) { rep(j, w) cin >> c[i][j]; } dfs(0, 0, 1); cout << ans << endl; }