#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, g[50][50];
int main() {
  while (scanf("%d %d", &n, &m) != EOF) {
    for (int i = (0), _b = (n); i < _b; ++i)
      for (int j = (0), _b = (m); j < _b; ++j) scanf("%d", &g[i][j]);
    scanf("%d %d", &a, &b);
    int res = (1 << 30);
    for (int i = (0), _b = (n); i < _b; ++i)
      for (int j = (0), _b = (m); j < _b; ++j) {
        int cur = 0;
        if (i + a - 1 < n && j + b - 1 < m) {
          for (int k = (i), _b = (i + a); k < _b; ++k)
            for (int l = (j), _b = (j + b); l < _b; ++l)
              if (g[k][l]) ++cur;
          res = min(res, cur);
        }
        cur = 0;
        if (i + b - 1 < n && j + a - 1 < m) {
          for (int k = (i), _b = (i + b); k < _b; ++k)
            for (int l = (j), _b = (j + a); l < _b; ++l)
              if (g[k][l]) ++cur;
          res = min(res, cur);
        }
      }
    printf("%d\n", res);
  }
  return 0;
}
