#include #include #include using namespace std; int main() { int h, w; cin >> h >> w; vector a(h); for (int i = 0; i < h; ++i) { cin >> a[i]; } assert(2 <= h && h <= 10); assert(2 <= w && w <= 10); for (int i = 0; i < h; ++i) { assert(a[i].length() == (size_t)w); } auto is_steppable = [&](int x, int y) { bool xx = 0 <= x && x < w; bool yy = 0 <= y && y < h; return xx && yy && (a[y][x] != '#'); }; int ans = 0; for (int bit = 0; bit < (1 << (h + w - 2)); ++bit) { int x = 0, y = 0, jewel = 1; for (int i = 0; i < (h + w - 2); ++i) { if (bit & (1 << i)) { x += 1; } else { y += 1; } if (!is_steppable(x, y)) { jewel = -1; break; } if (a[y][x] == 'o') { jewel += 1; } else { // a[y][x] == 'x' jewel -= 1; } if (jewel < 0) { break; } } if (jewel >= 0) { ans += 1; } } cout << ans << endl; return 0; }