#include using namespace std; using ll = long long; using ld = long double; #ifdef LOCAL #include #else #define debug(...) void(0) #endif #include using namespace atcoder; using mint = modint998244353; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int H, W; cin >> H >> W; vector A(H); for(int i = 0; i < H; i++) cin >> A[i]; int ans = 0; for(int bit = 0; bit < (1 << H + W - 2); bit++) { if(__builtin_popcount(bit) != H - 1) continue; int now = 1, ii = 0, jj = 0; bool f = 1; for(int i = 0; i < H + W - 2; i++) { if(bit & (1 << i)) ii++; else jj++; if(A[ii][jj] == 'o') { now++; }else if(A[ii][jj] == '#') { f = 0; break; }else { if(now == 0) { f = 0; break; }else { now--; } } } ans += f; } cout << ans << endl; }