def list3(a, b, c, *, val=0): return [[[val] * c for _ in range(b)] for _ in range(a)] H, W = map(int, input().split()) A = [input() for _ in range(H)] dp = list3(H, W, 22, val=0) dp[0][0][1] = 1 for i in range(H): for j in range(W): if A[i][j] == '#': continue for k in range(0, 21): if i-1 >= 0: x = k+1 if A[i][j] == 'o' else k-1 dp[i][j][x] += dp[i-1][j][k] if j-1 >= 0: x = k+1 if A[i][j] == 'o' else k-1 dp[i][j][x] += dp[i][j-1][k] ans = sum(dp[H-1][W-1][i] for i in range(0, 21)) print(ans)