#include using namespace std; using ll = long long; #define rep(i, n) for(int i = 0; i < n; i++) int main() { int H, W; cin >> H >> W; vector s(H); rep(i, H) cin >> s[i]; int ans = 0; using P = pair; queue

q; q.push(P(0, 1)); while(q.size()) { int t, c; tie(t, c) = q.front(); q.pop(); int y = t / W; int x = t % W; if(y == H - 1 && x == W - 1) ans++; if(y + 1 < H) { t = (y + 1) * W + x; if(s[y + 1][x] == 'o') { q.push(P(t, c + 1)); } else if(s[y + 1][x] == 'x') { if(c > 0) { q.push(P(t, c - 1)); } } } if(x + 1 < W) { t = y * W + x + 1; if(s[y][x + 1] == 'o') { q.push(P(t, c + 1)); } else if(s[y][x + 1] == 'x') { if(c > 0) { q.push(P(t, c - 1)); } } } } cout << ans << endl; }