#include <bits/stdc++.h>
using namespace std;
long long int g[50][50];
long long int cnt(long long int n, long long int m, long long int a,
                  long long int b) {
  long long int ans = +1e18;
  for (long long int i = 0; i <= n - a; ++i) {
    for (long long int j = 0; j <= m - b; ++j) {
      long long int c = 0;
      for (long long int x = i; x < i + a; ++x)
        for (long long int y = j; y < j + b; ++y)
          if (g[x][y]) ++c;
      ans = min(ans, c);
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m, a, b;
  cin >> n >> m;
  for (long long int i = 0; i < n; ++i)
    for (long long int j = 0; j < m; ++j) cin >> g[i][j];
  cin >> a >> b;
  cout << min(cnt(n, m, a, b), cnt(n, m, b, a)) << "\n";
  return 0;
}
