#include using namespace std; using lint = long long; template using V = vector; template using VV = V< V >; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int h, w, k; cin >> h >> w >> k; V s(h); for (auto&& e : s) cin >> e; VV< array > c(h + 1, V< array >(w + 1)); for (int i = h - 1; i >= 0; --i) for (int j = w - 1; j >= 0; --j) { for (int x = 0; x < 26; ++x) { c[i][j][x] = (s[i][j] - 'a' == x) + c[i + 1][j][x] + c[i][j + 1][x] - c[i + 1][j + 1][x]; } } auto fn = [&](int i, int j, int x) -> int { auto chk = [&](int a) -> bool { int s = 0; for (int l = 0; l < 26; ++l) { s += !!(c[i][j][l] - c[i + a][j][l] - c[i][j + a][l] + c[i + a][j + a][l]); } return s <= x; }; int ok = 0, ng = min(h - i, w - j) + 1; while (ng - ok > 1) { int mid = ok + ng >> 1; (chk(mid) ? ok : ng) = mid; } return ok; }; lint res = 0; for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) { res += fn(i, j, k) - fn(i, j, k - 1); } cout << res << '\n'; }