'''input''' i1=lambda:int(s1()) i2=lambda:map(int,s2()) il=lambda:list(i2()) s1=lambda:input() s2=lambda:s1().split() sl=lambda:list(s2()) '''output''' yn=lambda b:print("Yes" if b else "No") '''createList''' cl=lambda x,d:[d for i in range(x)]# a=c2l(10,23,"x") '''code''' from functools import cache H,W=i2() ma=[["#" for i in range(W+1)]for j in range(H+1)] for i in range(H): s=s1() for j in range(W): ma[i][j]=s[j] @cache def b(i,j,num): u=num if i==H-1 and j==W-1: return 1 if num==1: if ma[i][j]=="x": return 0 if ma[i][j]=="x": u-=1 if ma[i][j]=="o": u+=1 if ma[i][j]=="#": return 0 return b(i+1,j,u)+b(i,j+1,u) print(b(0,0,1))