#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 1;
int a[51][51];
int kapil(int n, int m, int p, int q) {
  int ans = 1e9;
  for (int i = 0; i < n - p + 1; i++) {
    for (int j = 0; j < m - q + 1; j++) {
      int cnt = 0;
      for (int k = i; k < i + p; k++) {
        for (int l = j; l < j + q; l++) {
          if (a[k][l] == 1) cnt++;
        }
      }
      ans = min(ans, cnt);
    }
  }
  return ans;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cin >> a[i][j];
  }
  int p, q;
  cin >> p >> q;
  cout << min(kapil(n, m, p, q), kapil(n, m, q, p)) << endl;
}
