#include <bits/stdc++.h>
using namespace std;
int n, m;
int a, b;
int mapp[55][55];
int ans1 = 0x3f3f3f3f;
int ans2(int ii, int jj, int ll, int rr) {
  int tmp = 0;
  for (int iii = ii; iii <= ll; iii++) {
    for (int jjj = jj; jjj <= rr; jjj++) {
      if (mapp[iii][jjj]) tmp++;
    }
  }
  return tmp;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &mapp[i][j]);
    }
  }
  scanf("%d%d", &a, &b);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int l, r;
      l = i + a - 1;
      r = j + b - 1;
      if (l <= n && r <= m) ans1 = min(ans1, ans2(i, j, l, r));
      l = i + b - 1;
      r = j + a - 1;
      if (l <= n && r <= m) ans1 = min(ans1, ans2(i, j, l, r));
    }
  }
  printf("%d", ans1);
  return 0;
}
