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 elif Map[x][y] == "o": j += 1 if x == H-1 and y == W-1: global ans ans += 1 return dfs(x+1, y, j) dfs(x, y+1, j) j = 0 dfs(0,0,j) print(ans)