#include <bits/stdc++.h>
using namespace std;
int tree[64][64];
int main() {
  int n, m;
  cin >> n >> m;
  int i, j;
  for (i = 0; i < n; ++i)
    for (j = 0; j < m; ++j) cin >> tree[i][j];
  int a, b;
  cin >> a >> b;
  int ans = 64 * 64;
  for (i = 0; i < n; ++i)
    for (j = 0; j < m; ++j) {
      int k, p;
      if (i + a > n || j + b > m) continue;
      int tmp = 0;
      for (k = i; k < i + a; ++k)
        for (p = j; p < j + b; ++p)
          if (tree[k][p]) ++tmp;
      if (ans > tmp) ans = tmp;
    }
  for (i = 0; i < n; ++i)
    for (j = 0; j < m; ++j) {
      int k, p;
      if (i + b > n || j + a > m) continue;
      int tmp = 0;
      for (k = i; k < i + b; ++k)
        for (p = j; p < j + a; ++p)
          if (tree[k][p]) ++tmp;
      if (ans > tmp) ans = tmp;
    }
  cout << ans << endl;
  return 0;
}
