#include #define all(vec) vec.begin(), vec.end() using namespace std; using ll = long long; using P = pair; constexpr ll INF = (1LL << 30) - 1LL; constexpr ll LINF = (1LL << 60) - 1LL; constexpr double eps = 1e-9; constexpr ll MOD = 1000000007LL; template bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }; template bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }; template ostream &operator<<(ostream &os, vector v) { for (int i = 0; i < v.size(); i++) { os << v[i] << (i + 1 == v.size() ? "\n" : " "); } return os; } template vector make_v(size_t a) { return vector(a); } template auto make_v(size_t a, Ts... ts) { return vector(ts...))>(a, make_v(ts...)); } template typename enable_if::value == 0>::type fill_v(T &t, const V &v) { t = v; } template typename enable_if::value != 0>::type fill_v(T &t, const V &v) { for (auto &e : t) { fill_v(e, v); } }; int co[1 << 11][1 << 11][26]; int h, w, k; int sum(int y1, int x1, int y2, int x2) { int res = 0; for (int k = 0; k < 26; k++) { if (co[y2][x2][k] - co[y1][x2][k] - co[y2][x1][k] + co[y1][x1][k] > 0) { res++; } } return res; } ll calc(int p) { ll res = 0; for (int i = 1; i < h; i++) { int y = i, x = 0; ll l = 0; while (x < w && y < h) { while (l <= x && sum(i + l, l, y + 1, x + 1) >= p) { l++; } res += l; x++; y++; } } for (int i = 0; i < w; i++) { int y = 0, x = i; int l = 0; while (x < w && y < h) { while (l <= y && sum(l, i + l, y + 1, x + 1) >= p) { l++; } res += l; x++; y++; } } return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> h >> w >> k; string s; for (int i = 0; i < h; i++) { cin >> s; for (int j = 0; j < w; j++) { co[i + 1][j + 1][s[j] - 'a']++; } } for (int i = 0; i <= h; i++) { for (int j = 1; j <= w; j++) { for (int k = 0; k < 26; k++) { co[i][j][k] += co[i][j - 1][k]; } } } for (int j = 0; j <= w; j++) { for (int i = 1; i <= h; i++) { for (int k = 0; k < 26; k++) { co[i][j][k] += co[i - 1][j][k]; } } } cout << calc(k) - calc(k + 1) << '\n'; }