#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 14;
long long n, m, k, f[maxn][maxn], ans = 0;
long long query(int i, int j){
i --; j--;
return f[i + k][j + k] - f[i][j + k] - f[i + k][j] + f[i][j];
}
void solve(){
cin >> n >> m >> k;
memset(f, 0, sizeof f);
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++) {
long long x;
cin >> x;
f[i][j] = f[i - 1][j] + f[i][j - 1] + x - f[i - 1][j - 1];
}
}
for (int i = 1; i <= n - k + 1; i++){
for (int j = 1; j <= m - k + 1; j++){
ans = max(ans, query(i,j));
}
}
cout << ans;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if (fopen("input.txt","r")) {
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
}
solve();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBtYXhuID0gM2UzICsgMTQ7CmxvbmcgbG9uZyBuLCBtLCBrLCBmW21heG5dW21heG5dLCBhbnMgPSAwOwpsb25nIGxvbmcgcXVlcnkoaW50IGksIGludCBqKXsKCWkgLS07IGotLTsKCXJldHVybiBmW2kgKyBrXVtqICsga10gLSBmW2ldW2ogKyBrXSAtIGZbaSArIGtdW2pdICsgZltpXVtqXTsKfQp2b2lkIHNvbHZlKCl7CgljaW4gPj4gbiA+PiBtID4+IGs7CgltZW1zZXQoZiwgMCwgc2l6ZW9mIGYpOwoJZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKXsKCQlmb3IgKGludCBqID0gMTsgaiA8PSBtOyBqKyspIHsKCQkJbG9uZyBsb25nIHg7CgkJCWNpbiA+PiB4OwoJCQlmW2ldW2pdID0gZltpIC0gMV1bal0gKyBmW2ldW2ogLSAxXSArIHggLSBmW2kgLSAxXVtqIC0gMV07CgkJfQoJfQoJZm9yIChpbnQgaSA9IDE7IGkgPD0gbiAtIGsgKyAxOyBpKyspewoJCWZvciAoaW50IGogPSAxOyBqIDw9IG0gLSBrICsgMTsgaisrKXsKCQkJYW5zID0gbWF4KGFucywgcXVlcnkoaSxqKSk7CgkJfQoJfQoJCgljb3V0IDw8IGFuczsKfQppbnQgbWFpbigpewoJaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsKCWNpbi50aWUoMCk7ICAgIGNvdXQudGllKDApOwoJaWYgKGZvcGVuKCJpbnB1dC50eHQiLCJyIikpIHsKCQlmcmVvcGVuKCJpbnB1dC50eHQiLCJyIixzdGRpbik7CgkJZnJlb3Blbigib3V0cHV0LnR4dCIsInciLHN0ZG91dCk7Cgl9Cglzb2x2ZSgpOwoJcmV0dXJuIDA7Cn0K