#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include int ri() { int n; scanf("%d", &n); return n; } int64_t rll() { long long n; scanf("%lld", &n); return n; } int main() { int h = ri(), w = ri(), k = ri(); std::string a[h]; for (int i = 0; i < h; i++) std::cin >> a[i]; int sum[h + 1][w + 1][26]; memset(sum, 0, sizeof(sum)); for (int j = 0; j < h; j++) for (int k = 0; k < w; k++) sum[j + 1][k + 1][a[j][k] - 'a']++; for (int i = 0; i <= h; i++) for (int j = 0; j < w; j++) for (int k = 0; k < 26; k++) sum[i][j + 1][k] += sum[i][j][k]; for (int i = 0; i < h; i++) for (int j = 0; j <= w; j++) for (int k = 0; k < 26; k++) sum[i + 1][j][k] += sum[i][j][k]; int64_t res = 0; int last_low[h + w - 1]; int last_high[h + w - 1]; for (int i = 0; i < h + w - 1; i++) { last_low[i] = -1; last_high[i] = -1; } for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { int tmp1, tmp2; const int max_size = std::min(h - i, w - j); { int start = last_low[i - j + w - 1] == -1 ? 0 : last_low[i - j + w - 1] - 1; int cur = start; while (cur < max_size) { int m = cur + 1; int cnt = 0; for (int k = 0; k < 26; k++) if (sum[i + m][j + m][k] + sum[i][j][k] != sum[i][j + m][k] + sum[i + m][j][k]) cnt++; if (cnt < k) cur++; else break; } last_low[i - j + w - 1] = tmp1 = cur; }{ int start = last_high[i - j + w - 1] == -1 ? 0 : last_high[i - j + w - 1] - 1; int cur = start; while (cur < max_size) { int m = cur + 1; int cnt = 0; for (int k = 0; k < 26; k++) if (sum[i + m][j + m][k] + sum[i][j][k] != sum[i][j + m][k] + sum[i + m][j][k]) cnt++; if (cnt <= k) cur++; else break; } last_high[i - j + w - 1] = tmp2 = cur; } res += tmp2 - tmp1; } } std::cout << res << std::endl; return 0; }