#include using namespace std; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((lint)(x).size()) #define POW2(n) (1LL << (n)) #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i=i##_begin_;i--) #define REP(i, n) FOR(i,0,n) #define IREP(i, n) IFOR(i,0,n) template bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; } template bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; } using lint = long long int; int dp[2001][2001][27]; int H, W, K; constexpr int INF = 100000; int main() { cin >> H >> W >> K; REP(i, H + 1) REP(j, W + 1) REP(d, 27) dp[i][j][d] = INF; REP(i, H) REP(j, W) { char c; cin >> c; dp[i][j][c - 'a'] = 1; } IREP(i, H) IREP(j, W) REP(d, 26) { mmin(dp[i][j][d], min({dp[i + 1][j][d], dp[i][j + 1][d], dp[i + 1][j + 1][d]}) + 1); } lint ret = 0; REP(i, H) REP(j, W) { vector v(27); REP(d, 27) v[d] = dp[i][j][d]; sort(v.begin(), v.end()); int d_max = min(H - i, W - j); ret += min(v[K] - 1, d_max) - min(v[K - 1] - 1, d_max); } cout << ret << endl; }