import sys input = sys.stdin.readline from collections import defaultdict mod=10**9+7 H,W=map(int,input().split()) MAP=[input().strip() for i in range(H)] if MAP[0][0]!=MAP[-1][-1]: print(0) exit() DP=dict() DP[0,0,H-1,W-1]=1 for i in range((H+W-2)//2): NDP=defaultdict(int) for x,y,z,w in DP: if 0<=x