#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b, minn = 30000;
  int mass[51][51];
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> mass[i][j];
  cin >> a >> b;
  for (int i = 1; i <= n - a + 1; i++)
    for (int j = 1; j <= m - b + 1; j++) {
      int kol = 0;
      for (int ii = i; ii <= i + a - 1; ii++)
        for (int jj = j; jj <= j + b - 1; jj++)
          if (mass[ii][jj] == 1) kol++;
      minn = min(minn, kol);
    }
  for (int i = 1; i <= n - b + 1; i++)
    for (int j = 1; j <= m - a + 1; j++) {
      int kol = 0;
      for (int ii = i; ii <= i + b - 1; ii++)
        for (int jj = j; jj <= j + a - 1; jj++)
          if (mass[ii][jj] == 1) kol++;
      minn = min(minn, kol);
    }
  cout << minn;
}
