#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b;
  cin >> n >> m;
  int **q = new int *[n];
  for (int i = 0; i < n; i++) q[i] = new int[m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> q[i][j];
  cin >> a >> b;
  int ans = 1000000;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (i + a <= n && j + b <= m) {
        int per = 0;
        for (int k = i; k < i + a; k++)
          for (int l = j; l < j + b; l++)
            if (q[k][l] == 1) per++;
        ans = min(ans, per);
      }
      if (i + b <= n && j + a <= m) {
        int per = 0;
        for (int k = i; k < i + b; k++)
          for (int l = j; l < j + a; l++)
            if (q[k][l] == 1) per++;
        ans = min(ans, per);
      }
    }
  cout << ans;
  return 0;
}
