using System.Collections.Generic; using System; class Perm { public static void Swap(ref T x, ref T y) { T tmp = x; x = y; y = tmp; } public static bool NextPermutation(T[] array, int index, int length, Comparison comp) { if (length <= 1) return false; for (int i = length - 1; i > 0; i--) { int k = i - 1; if (comp(array[k], array[i]) < 0) { int j = Array.FindLastIndex(array, delegate (T x) { return comp(array[k], x) < 0; }); Swap(ref array[k], ref array[j]); Array.Reverse(array, i, length - i); return true; } } Array.Reverse(array, index, length); return false; } public static bool NextPermutation(T[] array) where T : IComparable { return NextPermutation(array, 0, array.Length, Comparer.Default.Compare); } } public class hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var h = int.Parse(line[0]); var w = int.Parse(line[1]); var map = new char[h, w]; for (int i = 0; i < h; i++) { var s = Console.ReadLine().Trim(); for (int j = 0; j < w; j++) map[i, j] = s[j]; } getAns(h, w, map); } static bool check(char[,] map, int[] a) { var x = 0; var y = 0; var jw = 1; foreach (var z in a) { if (z == 0) x++; else y++; if (map[x, y] == 'o') jw++; else if (map[x, y] == 'x') { jw--; if (jw < 0) return false; } else return false; } return true; } static void getAns(int h, int w, char[,] map) { var a = new int[h + w - 2]; var c = 0; for (int i = h - 1; i < h + w - 2; i++) a[i] = 1; do { if (check(map, a)) c++; } while (Perm.NextPermutation(a)); Console.WriteLine(c); } }