from itertools import combinations def main(): H, W = map(int, input().split()) board = [list(input()) for _ in range(H)] ctr = 0 for h_dir in combinations(range(H + W - 2), H - 1): current = [0, 0] jewel = 1 for idx in range(H + W - 2): if idx in h_dir: current = [current[0] + 1, current[1]] else: current = [current[0], current[1] + 1] if board[current[0]][current[1]] == "#": break if board[current[0]][current[1]] == "o": jewel += 1 else: jewel -= 1 if jewel < 0: break else: ctr += 1 print(ctr) if __name__ == "__main__": main()