import sys input = sys.stdin.readline mod=10**9+7 H,W=map(int,input().split()) MAP=[input().strip() for i in range(H)] #H,W=200,200 #MAP=["a"*W for i in range(H)] if MAP[0][0]!=MAP[-1][-1]: print(0) exit() def cc(x,y,z,w): return x*8000000+y*40000+z*200+w def re(r): w=r%200 r//=200 z=r%200 r//=200 y=r%200 x=r//200 return x,y,z,w DP=dict() DP[cc(0,0,H-1,W-1)]=1 for i in range((H+W-2)//2): NDP=dict() for r in DP: x,y,z,w=re(r) if 0<=x