#include #include #include #include #include #include #include #include #define vv(a, b, c, d) vector >(a, vector(b, c)) #define vvi vector > #define vvl vector > #define vvv(a, b, c, d, e) vector > >(a, vector >(b, vector (c, d))) #define vvvl vector > > #define MODs 1000000007; typedef long long int ll; using namespace std; int main(int argc, char const *argv[]) { int H, W, K; std::cin >> H >> W >> K; std::vector c(H); for(int i=0;i> c[i]; vvi dp = vv(H, 26*W, 0, int); for(int i=0;i<26;i++){ dp[H-1][W-1+i*W] = (c[H-1][W-1]-'a'==i?1:-1); for(int j=0;j las(26); for(int k=0;k<26;k++) las[k] = (dp[i][j+k*W]==-1?1000000007:dp[i][j+k*W]); sort(las.begin(), las.end()); if(las[K-1]==1000000007) continue; ans += min({H-i + 1, W-j+ 1, las[K]}) - las[K-1] ; } } std::cout << ans << '\n'; return 0; }