#include <bits/stdc++.h>
using namespace std;
long long check(vector<vector<long long>> v, long long l, long long m,
                long long a, long long b) {
  long long k = 0;
  for (long long i = l; i < l + a; i++) {
    for (long long j = m; j < m + b; j++) {
      if (v[i][j]) k++;
    }
  }
  return k;
}
int main() {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> v(n, vector<long long>(m));
  for (auto &x : v)
    for (auto &y : x) cin >> y;
  long long a, b, k = INT_MAX;
  cin >> a >> b;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if ((j + a) <= m and (i + b) <= n) {
        long long p = check(v, i, j, b, a);
        k = min(p, k);
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if ((j + b) <= m and (i + a) <= n) {
        long long p = check(v, i, j, a, b);
        k = min(p, k);
      }
    }
  }
  cout << k << endl;
  return 0;
}
