H,W,K=map(int,input().split()) A=[[ord(a)-97 for a in input()] for h in range(H)] inf=1<<30 dp=[inf]*(26*W) ans=0 for h in range(H): prev=dp dp=[inf]*(26*W) for w in range(W): for a in range(26): if A[h][w]==a: dp[a*W+w]=0 if h: dp[a*W+w]=min(dp[a*W+w],prev[a*W+w]+1) if w: dp[a*W+w]=min(dp[a*W+w],dp[a*W+w-1]+1) if h and w: dp[a*W+w]=min(dp[a*W+w],prev[a*W+w-1]+1) idx=[dp[a*W+w] for a in range(26) if dp[a*W+w]<=min(h,w)] idx.append(min(h,w)+1) if len(idx)>K: idx.sort() ans+=idx[K]-idx[K-1] print(ans)