#include #include #include #include #include #include using namespace std; // #define int short #define endl "\n" const long long INF = (long long)1e18; const long long MOD = (long long)1e9 + 7; string yn(bool f){return f?"Yes":"No";} string YN(bool f){return f?"YES":"NO";} const int NUM = 26; int H, W, K; int con[2005][2005][26]; string squares[2000]; inline int check(int y, int x, int sz){ sz--; if(sz < 0) return 0; int y2 = y + sz, x2 = x + sz; if(y2 >= H || x2 >= W) return NUM+1; int level = 0; for(int i = 0; i < NUM; i++){ level += !!(con[y2+1][x2+1][i] - con[y2+1][x][i] - con[y][x2+1][i] + con[y][x][i]); } return level; } signed main(){ cin.tie(0); ios::sync_with_stdio(false); // cout<>H>>W>>K; for(int i = 0; i < H; i++){ cin>>squares[i]; for(int j = 0; j < W; j++){ con[i+1][j+1][squares[i][j] - 'a']++; } } for(int k = 0; k < NUM; k++){ for(int i = 0; i <= H; i++){ for(int j = 0; j <= W; j++){ con[i][j+1][k] += con[i][j][k]; if(i) con[i][j][k] += con[i-1][j][k]; } } } for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){ int minimum; if(H-i < W-j) minimum = H-i; else minimum = W-j; int h = minimum + 1, l = 0, m; int a, b; while(l + 1 < h){ m = (l + h)/2; if(check(i,j,m) > K){ h = m; } else { l = m; } } a = h; h = minimum + 1, l = 0; while(l + 1 < h){ m = (l + h)/2; if(!(check(i,j,m) < K)){ h = m; } else { l = m; } } b = l; ans += a - b - 1; } } cout<