#include <bits/stdc++.h>
using namespace std;
int ans = 2500, r, c, x, y, temp;
int fin_sum(int **pt, int ofx, int ofy) {
  int su = 0;
  for (int i = ofx; i < x + ofx; i++)
    for (int j = ofy; j < y + ofy; j++) su += (pt[i][j] != 0);
  return su;
}
int main() {
  cin >> r >> c;
  int **forest = new int *[r];
  for (int i = 0; i < r; i++) {
    forest[i] = new int[c];
    for (int j = 0; j < c; j++) cin >> forest[i][j];
  }
  cin >> x >> y;
  if (x <= r && y <= c) {
    for (int i = 0; i <= r - x; i++)
      for (int j = 0; j <= c - y; j++) ans = min(ans, fin_sum(forest, i, j));
  }
  temp = r;
  if (y <= r && x <= c) {
    swap(x, y);
    for (int i = 0; i <= r - x; i++)
      for (int j = 0; j <= c - y; j++) ans = min(ans, fin_sum(forest, i, j));
  }
  cout << ans << "\n";
  for (int i = 0; i < temp; i++) delete[] forest[i];
  delete[] forest;
  return 0;
}
