#include #include using namespace std; using ll = long long; int h,w,k; int a[2000][2000], r[2001][2001][26]; int main() { cin >> h >> w >> k; char c; for(int i=0;i> c; a[i][j] = int(c - 'a'); } } fill_n(r[0][0], 2001*2001*26, 1<<30); for(int i=h-1;i>=0;--i) { for(int j=w-1;j>=0;--j) { for(int ci=0;ci<26;++ci) { if(a[i][j] == ci) { r[i][j][ci] = 1; } else { r[i][j][ci] = min(1<<30, min({r[i+1][j][ci], r[i][j+1][ci], r[i+1][j+1][ci]}) + 1); if(r[i][j][ci] > min(h-i, w-j)) r[i][j][ci] = 1<<30; } } } } ll ans = 0; for(int i=0;i