#include using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define all(x) (x).begin(), (x).end() using ll = long long; using pii = pair; using vi = vector; using vll = vector; using vvi = vector>; const int inf = 1e9; int cs[26][2005][2005]; int ld[2005][2005]; int rd[2005][2005]; int cnt(int const i,int const j,int const d){ int res=0; rep(a,26) if(cs[a][i][j]+cs[a][i+d][j+d]-cs[a][i+d][j]-cs[a][i][j+d]) res++; // cout<> h >> w >> k; rep(i, h){ string s; cin >> s; rep(j,w) cs[s[j] - 'a'][i + 1][j + 1] = 1; } rep(a, 26) { rep(i, h) rep(j, w) cs[a][i + 1][j + 1] += cs[a][i + 1][j]; rep(j, w) rep(i, h) cs[a][i + 1][j + 1] += cs[a][i][j + 1]; } ll ans = 0; rep(i, h) rep(j, w){ int l,r; l=max(0,ld[i][j]-1); r=max(0,rd[i][j]-1); while(i+l