#include #include #include #include #include #define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD = 1000000007; // 998244353; const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; /*-------------------------------------------------*/ int cnt[26][2001][2001] = {}; int level(int y1, int x1, int y2, int x2) { int res = 0; REP(i, 26) { if (cnt[i][y2 + 1][x2 + 1] - cnt[i][y1][x2 + 1] - cnt[i][y2 + 1][x1] + cnt[i][y1][x1] > 0) ++res; } // cout << y1 << ' ' << x1 << ' ' << y2 << ' ' << x2 << '|' << res << '\n'; return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); // freopen("input.txt", "r", stdin); int h, w, k; cin >> h >> w >> k; REP(i, h) { string s; cin >> s; REP(j, w) { ++cnt[s[j] - 'a'][i + 1][j + 1]; REP(k, 26) cnt[k][i + 1][j + 1] += cnt[k][i + 1][j]; } } REP(k, 26) FOR(j, 1, w + 1) FOR(i, 1, h) cnt[k][i + 1][j] += cnt[k][i][j]; long long ans = 0; REP(i, h) REP(j, w) { int lb = -1; int ub = h - i; if (ub > w - j - 1) ub = w - j; while (ub - lb > 1) { int mid = (lb + ub) / 2; (level(i, j, i + mid, j + mid) >= k ? ub : lb) = mid; } int tmp = ub; lb = -1; ub = h - i; if (ub > w - j) ub = w - j; while (ub - lb > 1) { int mid = (lb + ub) / 2; (level(i, j, i + mid, j + mid) > k ? ub : lb) = mid; } ans += ub - tmp; // cout << i << ' ' << j << ' ' << tmp << ' ' << ub << '\n'; } cout << ans << '\n'; return 0; }