#include using namespace std; int rui[26][2010][2010] = {}; int h, w; char c[2010][2010]; bool isOK(int i, int j, int ha, int num){ int ans = 0; for(int x = 0;x < 26;x++){ if(rui[x][i+ha+1][j+ha+1] - rui[x][i+ha+1][j] - rui[x][i][j+ha+1] + rui[x][i][j] > 0){ ans++; } } return ans >= num; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int k; cin >> h >> w >> k; for(int i = 0;i < h;i++){ cin >> c[i]; for(int j = 0;j < w;j++){ rui[c[i][j]-'a'][i+1][j+1] = 1; } } for(int x = 0;x < 26;x++){ for(int i = 0;i <= h;i++){ for(int j = 0;j <= w;j++){ rui[x][i+1][j] += rui[x][i][j]; } } } for(int x = 0;x < 26;x++){ for(int i = 0;i <= h;i++){ for(int j = 0;j <= w;j++){ rui[x][i][j+1] += rui[x][i][j]; } } } long long ans = 0; for(int i = 0;i < h;i++){ for(int j = 0;j < w;j++){ int l, r; l = 0; r = min(h-i, w-j); while(r-l > 1){ int mid = (l+r)/2; if(isOK(i, j, mid, k)) r = mid; else l = mid; } int l2, r2; l2 = l; r2 = min(h-i, w-j); while(r2-l2 > 1){ int mid = (l2+r2)/2; if(isOK(i, j, mid, k+1)) r2 = mid; else l2 = mid; } ans += l2-l; } } cout << ans << endl; return 0; }