#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
int a[50][50];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  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 x, y;
  cin >> x >> y;
  if (x > y) swap(x, y);
  ;
  int ans = 1000000000;
  for (int i = 0; i <= n - min(x, y); i++) {
    for (int j = 0; j <= m - min(x, y); j++) {
      int cnt = 0;
      if (j + y <= m) {
        for (int z = i; z < i + x; z++) {
          for (int w = j; w < j + y; w++)
            if (a[z][w] == 1) cnt++;
        }
        ans = min(ans, cnt);
      }
      cnt = 0;
      if (i + y <= n) {
        for (int z = i; z < i + y; z++) {
          for (int w = j; w < j + x; w++)
            if (a[z][w] == 1) cnt++;
        }
        ans = min(ans, cnt);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
