H,W = map(int,input().split()) S = [list(input()) for _ in range(H)] INFTY = 10**9 D = {chr(i):i-96 for i in range(97,123)} D[INFTY] = INFTY Pa = {} dp = [[INFTY for _ in range(W)] for _ in range(H)] dp[0][0] = D[S[0][0]] Pa[(0,0)] = -1 for i in range(H): for j in range(W): if i+1=D[S[i+1][j]]: if dp[i][j]+D[S[i+1][j]]