#include <bits/stdc++.h>
using namespace std;
const long long mod1 = 998244353;
const long long mod2 = 1000000007;
bool v[55][55];
int suf[55][55];
int n, m, a, b, res = 0x3f3f3f3f;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a);
      v[i][j] = a;
      suf[i][j] = suf[i][j - 1] + suf[i - 1][j] - suf[i - 1][j - 1] + a;
    }
  scanf("%d%d", &a, &b);
  for (int i = 0; i <= n - a; i++)
    for (int j = 0; j <= m - b; j++)
      res = min(res,
                suf[i + a][j + b] + suf[i][j] - suf[i + a][j] - suf[i][j + b]);
  for (int i = 0; i <= n - b; i++)
    for (int j = 0; j <= m - a; j++)
      res = min(res,
                suf[i + b][j + a] + suf[i][j] - suf[i + b][j] - suf[i][j + a]);
  printf("%d\n", res);
  return 0;
}
