#include #define rep(i,a,b) for(int i=a;i=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; templatebool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } templatebool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; } //--------------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )  Welcome to My Coding Space!      ( ´_ゝ`) /  ⌒i @hamayanhamayan     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ int H, W, K; string C[2010]; //--------------------------------------------------------------------------------------------------- int buf[26][2010][2010]; void init() { rep(y, 0, H) rep(x, 0, W) buf[C[y][x] - 'a'][y + 1][x + 1]++; rep(c, 0, 26) rep(y, 1, H + 2) rep(x, 1, W + 2) { buf[c][y][x] += buf[c][y - 1][x] + buf[c][y][x - 1] - buf[c][y - 1][x - 1]; } } //--------------------------------------------------------------------------------------------------- int binarySearch(int x, int y, int l, int r, int limit) { //[l,r) int ng = l - 1, ok = r; while (ng + 1 != ok) { int md = (ng + ok) / 2; int res = 0; rep(c, 0, 26) if (0 < buf[c][y + md][x + md] - buf[c][y + md][x] - buf[c][y][x + md] + buf[c][y][x]) res++; if (limit <= res) ok = md; else ng = md; } return ok; } //--------------------------------------------------------------------------------------------------- void _main() { cin >> H >> W >> K; rep(y, 0, H) cin >> C[y]; init(); ll ans = 0; rep(y, 0, H) rep(x, 0, W) { int maxlen = min(W - x, H - y); ans += binarySearch(x, y, 1, maxlen + 1, K + 1) - binarySearch(x, y, 1, maxlen + 1, K); } cout << ans << endl; }