#include <bits/stdc++.h>
int g[105][105], n, m, a, b, ans = 3000, Max, Min;
int down(int ii, int jj, int a, int b) {
  int an = 0;
  for (int i = ii; i <= ii + a; i++)
    for (int j = jj; j <= jj + b; j++)
      if (g[i][j]) an++;
  return an;
}
int main() {
  for (int i = 1; i <= 100; i++)
    for (int j = 1; j <= 100; j++) g[i][j] = 1;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &g[i][j]);
  scanf("%d%d", &a, &b);
  a--, b--;
  if (a > b)
    Max = a, Min = b;
  else
    Max = b, Min = a;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      ans = (ans < (down(i, j, a, b) < down(i, j, b, a) ? down(i, j, a, b)
                                                        : down(i, j, b, a))
                 ? ans
                 : (down(i, j, a, b) < down(i, j, b, a) ? down(i, j, a, b)
                                                        : down(i, j, b, a)));
  printf("%d\n", ans);
  return 0;
}
