#pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target ("avx") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using Int = long long; template ostream &operator<<(ostream &os, const pair &a) { return os << "(" << a.first << ", " << a.second << ")"; }; template void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; } template void chmin(T &t, const T &f) { if (t > f) t = f; } template void chmax(T &t, const T &f) { if (t < f) t = f; } int H, W, K; char C[2010][2010]; int sum[2010][2010][26]; inline int calc(int x0, int x1, int y0, int y1, int e) { return sum[x0][y0][e] - sum[x0][y1][e] - sum[x1][y0][e] + sum[x1][y1][e]; } inline int get(int x, int y, int l) { int ret = 0; for (int e = 0; e < 26; ++e) { if (calc(x, x + l, y, y + l, e) > 0) { ++ret; } } return ret; } int main() { for (; ~scanf("%d%d%d", &H, &W, &K); ) { for (int x = 0; x < H; ++x) { scanf("%s", C[x]); } for (int x = 0; x < H; ++x) for (int y = 0; y < W; ++y) { for (int e = 0; e < 26; ++e) { sum[x + 1][y + 1][e] = sum[x + 1][y][e] + sum[x][y + 1][e] - sum[x][y][e] + ((C[x][y] - 'a' == e) ? 1 : 0); } } Int ans = 0; for (int s = 0; s < 2; ++s) { for (int x = 0; x < H; ++x) { int l = 1; for (int y = 0; y < W; ++y) { --l; for (; x + l <= H && y + l <= W && get(x, y, l) < K + s; ++l) {} ans += (s == 0) ? -l : +l; } } } printf("%lld\n", ans); } return 0; }