#include using namespace std; using ll = long long; int cnt[26][2001][2001]; int main() { cin.tie(0); ios::sync_with_stdio(false); int h, w, K; cin >> h >> w >> K; vector c(h); for (int i = 0; i < h; i++) { cin >> c[i]; for (int j = 0; j < w; j++) { for (int k = 0; k < 26; k++) { cnt[k][i + 1][j + 1] = cnt[k][i + 1][j]; } cnt[c[i][j] - 'a'][i + 1][j + 1]++; } } for (int i = 1; i <= h; i++) { for (int j = 0; j <= w; j++) { for (int k = 0; k < 26; k++) { cnt[k][i][j] += cnt[k][i - 1][j]; } } } ll ans = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { int sz = min(i + 1, j + 1); int ng = 0, ok = sz + 1; while (ok - ng > 1) { int mid = (ok + ng) / 2; int val = 0; for (int k = 0; k < 26; k++) { bool hoge = bool(cnt[k][i + 1][j + 1] + cnt[k][i + 1 - mid][j + 1 - mid] - cnt[k][i + 1][j + 1 - mid] - cnt[k][i + 1 - mid][j + 1]); val += hoge; } if (val >= K) { ok = mid; } else { ng = mid; } } if (ok <= 0 || ok > sz) continue; int ng2 = sz + 1, ok2 = -1; while (ng2 - ok2 > 1) { int mid = (ok2 + ng2) / 2; int val = 0; for (int k = 0; k < 26; k++) { bool hoge = bool(cnt[k][i + 1][j + 1] + cnt[k][i + 1 - mid][j + 1 - mid] - cnt[k][i + 1][j + 1 - mid] - cnt[k][i + 1 - mid][j + 1]); val += hoge; } if (val <= K) { ok2 = mid; } else { ng2 = mid; } } if (ok2 <= 0 || ok2 > sz || ok > ok2) continue; ans += ok2 - ok + 1; //cerr << i << " " << j << ": " << ok << " " << ok2 << endl; } } cout << ans << "\n"; return 0; }