#include <bits/stdc++.h>
using namespace std;
map<long long int, long long int> mp, mk;
set<long long int> s1, s2;
vector<long long int> v, w;
string s = "", p = "", q = "";
char ch;
long long int m, n, c = 1e9, i, j, k, l, r, x, y, u, e, f, g, h, mn, mx, d, z,
                    a, b;
int main() {
  cin >> n >> m;
  long long int t[n][m];
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) cin >> t[i][j];
  cin >> a >> b;
  for (i = 0; i < n - a + 1; i++) {
    for (j = 0; j < m - b + 1; j++) {
      d = 0;
      for (k = i; k < i + a; k++)
        for (l = j; l < j + b; l++)
          if (t[k][l] == 1) d++;
      c = min(c, d);
    }
  }
  for (i = 0; i < n - b + 1; i++) {
    for (j = 0; j < m - a + 1; j++) {
      d = 0;
      for (k = i; k < i + b; k++)
        for (l = j; l < j + a; l++)
          if (t[k][l] == 1) d++;
      c = min(c, d);
    }
  }
  cout << c << endl;
}
