#include using namespace std; //#pragma GCC optimize("Ofast") #define rep(i,n) for(ll i=0;i=0;i--) #define perl(i,r,l) for(ll i=r-1;i>=l;i--) #define fi first #define se second #define pb push_back #define ins insert #define pqueue(x) priority_queue,greater> #define all(x) (x).begin(),(x).end() #define CST(x) cout<> #define rev(x) reverse(x); using ll=long long; using vl=vector; using vvl=vector>; using pl=pair; using vpl=vector; using vvpl=vector; const ll MOD=1000000007; const ll MOD9=998244353; const int inf=1e9+10; const ll INF=4e18; const ll dy[9]={1,0,-1,0,1,1,-1,-1,0}; const ll dx[9]={0,1,0,-1,1,-1,1,-1,0}; template inline bool chmin(T& a, T b) { if (a >= b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } ll sdx[3]={1,0,1}; ll sdy[3]={0,1,1}; int main(){ ll h,w,z;cin >> h >> w >> z; vector g(h);rep(i,h)cin >> g[i]; vector dp(26,vvl(h,vl(w,INF))); rep(k,26){ per(i,h){ per(j,w){ rep(f,3){ ll nx=i+sdx[f],ny=j+sdy[f]; if(nx>=h||ny>=w)continue; if(dp[k][nx][ny]==INF)continue; ll to=dp[k][nx][ny]+1; if(i+to<=h&&j+to<=w){ chmin(dp[k][i][j],dp[k][nx][ny]+1); } } if(g[i][j]==char('a'+k))dp[k][i][j]=1; } } } /*rep(i,h){ rep(j,w)cout << dp[3][i][j] <<" ";cout << endl; }*/ ll ans=0; rep(i,h){ rep(j,w){ vl cand={0}; cand.emplace_back(min(h-i,w-j)+1); rep(k,26){ if(dp[k][i][j]!=INF)cand.emplace_back(dp[k][i][j]); } sort(all(cand)); /*if(i==0&&j==0){ for(auto p:cand)cout << p <<" ";cout << endl; }*/ //cout << cand.size() << endl; if(cand.size()>z+1){ ans+=cand[z+1]-cand[z]; cout << i <<" " << j <<" " << cand[z+1]-cand[z] << endl; } } } cout << ans << endl; }