H, W=map(int, input().split()) S=list(input() for i in range(H)) # dp[h][w][n] で h行w列で宝石をn個持っている場合の数 dp=[[[0 for k in range(109)] for j in range(W)] for i in range(H)] dp[0][0][1]=1 ans=0 for h in range(H): for w in range(W): for n in range(109): for dh, dw in ((1,0),(0,1)): nh, nw=h+dh, w+dw if (nh=0: dp[nh][nw][n-1]+=dp[h][w][n] for n in range(len(dp[0][0])): ans+=dp[H-1][W-1][n] print(ans) # print(dp)