#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b;
  cin >> n >> m;
  int tr[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> tr[i][j];
      tr[i][j] = 1 - tr[i][j];
    }
  }
  cin >> a >> b;
  int ans = 0;
  for (int i = 0; i <= n - a; i++)
    for (int j = 0; j <= m - b; j++) {
      int newans = 0;
      for (int c = 0; c < a; c++)
        for (int d = 0; d < b; d++) newans += tr[i + c][j + d];
      ans = max(ans, newans);
    }
  a = a + b;
  b = a - b;
  a = a - b;
  for (int i = 0; i <= n - a; i++)
    for (int j = 0; j <= m - b; j++) {
      int newans = 0;
      for (int c = 0; c < a; c++)
        for (int d = 0; d < b; d++) newans += tr[i + c][j + d];
      ans = max(ans, newans);
    }
  cout << a * b - ans << endl;
  return 0;
}
