H, W = map(int, input().split()) Map = [input() for i in range(H)] ans = 0 def dfs(x, y, j): if x < 0 or x >= H or y < 0 or y >= W or Map[x][y] == "#": return if Map[x][y] == "x" and j-1 == 0: return if Map[x][y] == "x": j -= 1 else: j += 1 if x == W-1 and y == H-1: global ans ans += 1 return dfs(x+1, y, j) dfs(x, y+1, j) j = 1 dfs(0,0,j) print(ans)