#include <bits/stdc++.h>
using namespace std;
const int N = 51;
int a[N][N], n, m;
int solve(int a1, int b1) {
  int ans, Min = 1 << 20;
  for (int i = 1; i <= n - a1 + 1; i++)
    for (int j = 1; j <= m - b1 + 1; j++) {
      ans = 0;
      for (int k = i; k <= i + a1 - 1; k++)
        for (int z = j; z <= j + b1 - 1; z++)
          if (a[k][z] == 1) ans++;
      Min = min(ans, Min);
    }
  return Min;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
  int a, b;
  scanf("%d%d", &a, &b);
  printf("%d\n", min(solve(a, b), solve(b, a)));
  return 0;
}
