def count_valid_routes(H, W, grid): dp = [[0]*W for _ in range(H)] dp[0][0] = 1 if grid[0][0] == 'o' else 0 gems = [[0 for _ in range(W+1)] for _ in range(H+1)] gems[1][1] = 1 if grid[0][0] == 'o' else 0 if any('x' in row for row in grid): for i in range(H): for j in range(W): if grid[i][j] == '#': continue if i > 0: dp[i][j] = max(dp[i][j], dp[i-1][j] + (grid[i][j] == 'o') - (grid[i][j] == 'x')) if j > 0: dp[i][j] = max(dp[i][j], dp[i][j-1] + (grid[i][j] == 'o') - (grid[i][j] == 'x')) if dp[i][j] < 0: dp[i][j] = 0 else: for i in range(1, H+1): for j in range(1, W+1): if i == 1 and j == 1: continue if grid[i-1][j-1] == '#': continue if grid[i-1][j-1] == 'o': gems[i][j] = max(gems[i-1][j], gems[i][j-1]) + 1 else: gems[i][j] = max(gems[i-1][j], gems[i][j-1]) - 1 if gems[i][j] >= 0: dp[i-1][j-1] = dp[i-2][j-1] + dp[i-1][j-2] return dp[-1][-1] if dp[-1][-1] >= 0 else 0 H, W = map(int, input().split()) grid = [input() for _ in range(H)] print(count_valid_routes(H, W, grid))