H, W = map(int, input().split()) A = [input() for _ in range(H)] answer = 0 perm = [["", 0, 0]] for _ in range(H+W-2): np = [] for p in perm: if p[1] != W-1: np.append([p[0]+"D", p[1]+1, p[2]]) if p[2] != H-1: np.append([p[0]+"R", p[1], p[2]+1]) perm = np for pattern in perm: pattern = pattern[0] cnt = 1 h, w = 0, 0 for p in pattern: if p == "D": h += 1 else: w += 1 if A[h][w] == "#": break elif A[h][w] == "x": cnt -= 1 if cnt < 0: break else: cnt += 1 else: answer += 1 print(answer)