#include #include #include #include #include #include #include #include #include using namespace atcoder; using namespace std; using ll = long long; #define Sort(a) sort((a).begin(), (a).end()) #define Rev(a) reverse((a).begin(), (a).end()) #define cfs(a) cout << fixed << setprecision(a) int main() { ll H, W; cin >> H >> W; vector A(H); for (int i = 0; i < H; i++) { cin >> A[i]; } ll all = (H - 1) + (W - 1); ll ans = 0; for (ll i = 0; i < pow(2, all); i++) { bool ok = true; ll have = 1; ll now_h = 0; ll now_w = 0; ll div = 1; ll rem = i; for (ll j = 0; j < all; j++) { rem /= div; if (rem % 2 == 0) { now_h++; if (now_h >= H) { ok = false; } } else { now_w++; if (now_w >= W) { ok = false; } } div *= 2; rem = i; if (!ok) { break; } if (A[now_h][now_w] == '#') { ok = false; break; } if (A[now_h][now_w] == 'o') { have++; } if (A[now_h][now_w] == 'x') { have--; if (have < 0) { ok = false; break; } } } if (ok) { ans++; } } cout << ans << endl; }