#include <bits/stdc++.h>
using namespace std;
const int N = 60;
bool st1[N][N], st2[N][N];
;
int m, n;
int main() {
  int i, j, k;
  int a, b;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      scanf("%d", &k);
      if (k) st1[i][j] = st2[j][i] = true;
    }
  int ans = 1000000;
  scanf("%d%d", &a, &b);
  for (i = 1; i + a - 1 <= n; i++)
    for (j = 1; j + b - 1 <= m; j++) {
      k = 0;
      for (int ii = i; ii <= i + a - 1; ii++)
        for (int jj = j; jj <= j + b - 1; jj++)
          if (st1[ii][jj]) k++;
      ans = min(k, ans);
    }
  for (i = 1; i + a - 1 <= m; i++)
    for (j = 1; j + b - 1 <= n; j++) {
      k = 0;
      for (int ii = i; ii <= i + a - 1; ii++)
        for (int jj = j; jj <= j + b - 1; jj++)
          if (st2[ii][jj]) k++;
      ans = min(k, ans);
    }
  printf("%d\n", ans);
  return 0;
}
