from itertools import permutations H, W = map(int, input().split()) A = [input() for _ in range(H)] answer = 0 perm = list(set(permutations("D"*(H-1)+"R"*(W-1), H+W-2))) for pattern in perm: cnt = 1 h, w = 0, 0 for p in pattern: if p == "D": h += 1 else: w += 1 if A[h][w] == "#": break elif A[h][w] == "x": cnt -= 1 if cnt < 0: break else: cnt += 1 else: answer += 1 print(answer)