h,w=map(int,input().split()) a=[input()for i in range(h)] g=[[[0]*20 for i in range(w)]for j in range(h)] g[0][0][1] = 1 for i in range(h): for j in range(w): if a[i][j]=='#': continue if i>=1: for k in range(20): t=k+(a[i][j]=='o')*2-1 if 0<=t<20: g[i][j][t] += g[i-1][j][k] if j>=1: for k in range(20): t=k+(a[i][j]=='o')*2-1 if 0<=t<20: g[i][j][t] += g[i][j-1][k] print(sum(g[h-1][w-1]))