#include <bits/stdc++.h>
using namespace std;
unsigned u[52][52];
int main() {
  int n, i, j, i1, j1, m, r, res, a, b;
  cin >> n >> m;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) cin >> u[i][j];
  cin >> a >> b;
  res = a * b;
  for (i = 0; i <= n - a; i++)
    for (j = 0; j <= m - b; j++) {
      r = 0;
      for (i1 = i; i1 < i + a; i1++)
        for (j1 = j; j1 < j + b; j1++) r += u[i1][j1];
      if (r < res) res = r;
    }
  swap(a, b);
  for (i = 0; i <= n - a; i++)
    for (j = 0; j <= m - b; j++) {
      r = 0;
      for (i1 = i; i1 < i + a; i1++)
        for (j1 = j; j1 < j + b; j1++) r += u[i1][j1];
      if (r < res) res = r;
    }
  cout << res << endl;
  return 0;
}
