import std, core.bitop; bool chmin(T)(ref T SE, T MI) { if (SE > MI) { SE = MI; return true; } else { return false; } } bool chmax(T)(ref T SE, T MI) { if (SE < MI) { SE = MI; return true; } else { return false; } } int lowerBound(T)(T[] SE, T MI) { int lo = -1, hi = cast(int)(SE.length); while (hi - lo > 1) { int mid = lo + hi >> 1; (SE[mid] < MI ? lo : hi) = mid; } return hi; } int upperBound(T)(T[] SE, T MI) { int lo = -1, hi = cast(int)(SE.length); while (hi - lo > 1) { int mid = lo + hi >> 1; (SE[mid] > MI ? hi : lo) = mid; } return hi; } void main() { int H, W; readf("%s %s\n", H, W); string[] A; foreach (i; 0 .. H) { A ~= readln.chomp; } int ans; foreach (i; 0 .. 1 << H + W - 2) { if (popcnt(i) == H - 1) { bool ok = true; int X, Y; int cnt = 1; foreach (j; 0 .. H + W - 2) { ++(i >> j & 1 ? X : Y); cnt += (A[X][Y] == 'o' ? 1 : -1); ok &= A[X][Y] != '#'; ok &= cnt >= 0; } ans += ok; } } ans.writeln; }