fn c(n: usize, m: usize) -> Vec { let mut r = Vec::new(); let mut c = (1u64 << m) - 1; while c < (1u64 << n) { r.push(c); let x = c & (!c + 1); let y = c + x; let z = c & !y; c = (z / x) >> 1 | y; } r } fn g() -> String { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s } fn main() { let n: Vec = g().split_whitespace().flat_map(str::parse).collect(); let a: Vec> = (0..n[0]).map(|_| g().trim().chars().collect()).collect(); let mut r = 0; for mut i in c(n[0] + n[1] - 2, n[0] - 1) { let (mut d, mut h, mut w) = (0, 0, 0); while h < n[0] && w < n[1] { match a[h][w] { 'o' => d += 1, 'x' => d -= 1, _ => break, } if d < 0 { break; } match i & 1 { 1 => h += 1, _ => w += 1, } i >>= 1; } if d >= 0 && h + 1 == n[0] && w == n[1] { r += 1 } } println!("{r}") }