#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b;
  cin >> n >> m;
  int arr[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
    }
  }
  cin >> a >> b;
  vector<int> cut;
  for (int i = 0; i <= n - a; i++) {
    for (int j = 0; j <= m - b; j++) {
      int c = 0;
      for (int x = i; x < i + a; x++) {
        for (int y = j; y < j + b; y++) {
          if (arr[x][y] == 1) {
            c++;
          }
        }
      }
      cut.push_back(c);
    }
  }
  for (int i = 0; i <= n - b; i++) {
    for (int j = 0; j <= m - a; j++) {
      int c = 0;
      for (int x = i; x < i + b; x++) {
        for (int y = j; y < j + a; y++) {
          if (arr[x][y] == 1) {
            c++;
          }
        }
      }
      cut.push_back(c);
    }
  }
  sort(cut.begin(), cut.end());
  cout << cut[0];
  return 0;
}
