H, W = map(int, input().split()) A = [list(input()) for _ in range(H)] def dfs(h, w, c): cnt = 0 if h == H-1 and w == W-1: return 1 if A[h][w] == "o": c += 1 elif A[h][w] == "x": c -= 1 if h < H-1 and A[h+1][w] != "#" and (c >= 1 or A[h+1][w] != "x"): cnt += dfs(h+1, w, c) if w < W-1 and A[h][w+1] != "#" and (c >= 1 or A[h][w+1] != "x"): cnt += dfs(h, w+1, c) return cnt print(dfs(0, 0, 0))