def rec(cy,cx,cc): if A[cy][cx] == "o": nc = cc + 1 else: if cc == 0: return else: nc = cc - 1 if cy == H-1 and cx == W-1: res[0] += 1 return for i in range(2): ny,nx = cy +dy[i],cx+dx[i] if not (0 <= ny < H and 0 <= nx < W): continue if A[ny][nx] == "#": continue rec(ny,nx,nc) H,W = map(int,input().split()) A = [] for _ in range(H): a = input() A.append(a) dy = (0,1) dx = (1,0) res = [0] rec(0,0,0) print(res[0])