#define _USE_MATH_DEFINES #include #include #include #include #include #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; //using namespace boost::multiprecision; const double EPS = 1e-10; long long const MOD = 1000000007; long long mod_pow(long long x, long long n) { long long res = 1; for (int i = 0;i < 60; i++) { if (n >> i & 1) res = res * x % MOD; x = x * x % MOD; } return res; } template T gcd(T a, T b) { return b != 0 ? gcd(b, a % b) : a; } template T lcm(T a, T b) { return a * b / gcd(a, b); } void fastInput() { cin.tie(0); ios::sync_with_stdio(false); } vector Divisor(long long n) { vector ret; for(long long i=1; i*i<=n; i++) { if(n % i == 0) { ret.push_back(i); if(i*i!=n) ret.push_back(n / i); } } return ret; } int ruiseki[2001][2001][26]; char field[2001][2001]; int H, W, K; int calc(int lw, int lh, int rw, int rh) { int ret = 0; for (int i = 0; i < 26; i++) { int a = ruiseki[rh][rw][i] + ruiseki[lh-1][lw-1][i]; a -= ruiseki[lh-1][rw][i]; a -= ruiseki[rh][lw-1][i]; if (a > 0) ret++; } return ret; } int shakutori(int sW, int sH, int N) { int lw = sW; int lh = sH; int rw = sW; int rh = sH; long long ret = 0; for (; lw <= W && lh <= H; lw++, lh++) { while (rw <= W && rh <= H && calc(lw, lh, rw, rh) <= N) { rw++; rh++; } ret += rw - lw; if (rw < lw) { rw++; rh++; } } return ret; } int main(void) { cin >> H >> W >> K; for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { cin >> field[i][j]; } } for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { ruiseki[i][j][field[i][j] - 'a']++; for (int k = 0; k < 26; k++) { ruiseki[i][j][k] += ruiseki[i][j-1][k]; } } } for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { for (int k = 0; k < 26; k++) { ruiseki[i][j][k] += ruiseki[i-1][j][k]; } } } long long ans = 0; for (int i = 1; i <= W; i++) { ans += shakutori(i, 1, K) - shakutori(i, 1, K-1); } for (int i = 2; i <= H; i++) { ans += shakutori(1, i, K) - shakutori(1, i, K-1); } cout << ans << endl; }