#include #include using namespace std; #pragma warning (disable: 4996) long long H, W, K, ans; char c[2009][2009]; int p[2009][2009][27]; int main() { cin >> H >> W >> K; for (int i = 0; i < H; i++) scanf("%s", &c[i]); for (int t = 0; t < 27; t++) { for (int i = H; i >= 0; i--) { int z = ('a' + t); for (int j = W; j >= 0; j--) { if (c[i][j] == z) p[i][j][t] = 1; else p[i][j][t] = min({ (int)min(H - i, W - j) + 1, p[i][j + 1][t], p[i + 1][j][t], p[i + 1][j + 1][t] }) + 1; } } } for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { sort(p[i][j], p[i][j] + 26); ans += 1LL * (p[i][j][K] - p[i][j][K - 1]); } } cout << ans << endl; return 0; }