h, w = map(int, input().split()) a = [input() for _ in range(h)] m = 25 dp = [[[0] * m for _ in range(w)] for _ in range(h)] dp[0][0][1] = 1 for i in range(h): for j in range(w): if i: if a[i][j] == "#": continue elif a[i][j] == "o": for k in range(m-1): dp[i][j][k+1] += dp[i-1][j][k] else: for k in range(1, m): dp[i][j][k-1] += dp[i-1][j][k] if j: if a[i][j] == "#": continue elif a[i][j] == "o": for k in range(m-1): dp[i][j][k+1] += dp[i][j-1][k] else: for k in range(1, m): dp[i][j][k-1] += dp[i][j-1][k] print(sum(dp[-1][-1][1:]))