#include <bits/stdc++.h>
using namespace std;
string s;
int n,m,b[10000][10000],a[10000][10000],m1,n1,gtln=INT_MIN;

int main()
{
    freopen("Matran.inp","r",stdin);
    freopen("matranb.out","w",stdout);
    cin>>m>>n>>m1>>n1;
    for (int i=1;i<m+1;i++)
    {
        for (int j=1;j<n+1;j++)
        {
            cin>>a[i][j];
            b[i][j]=a[i][j]+b[i-1][j]+b[i][j-1]-b[i-1][j-1];
        }
    }
    for (int i=m1;i<m+1;i++)
    {
        for (int j=n1;j<n+1;j++)
        {
            gtln=max(gtln,b[i][j]-b[i-m1][j]-b[i][j-n1]+b[i-m1][j-n1]);
        }
    }
    cout<<gtln;

}

