#include <bits/stdc++.h>
using namespace std;
int main() {
  int t = 1;
  while (t--) {
    int n, m, i, j, a, b;
    cin >> n >> m;
    vector<int> v1, v2;
    vector<vector<int>> garden;
    vector<vector<int>> v3;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        cin >> a;
        v1.push_back(a);
      }
      garden.push_back(v1);
      v1.clear();
    }
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
      }
    }
    cin >> a >> b;
    int min = n * m;
    if (n >= a && m >= b) {
      for (size_t i = 0; i < n - a + 1; ++i) {
        for (size_t j = 0; j < m - b + 1; ++j) {
          size_t localmin = 0;
          for (size_t ii = i; ii < i + a; ++ii) {
            for (size_t jj = j; jj < j + b; ++jj) {
              if (garden[ii][jj] == 1) ++localmin;
            }
          }
          if (localmin < min) {
            min = localmin;
          }
        }
      }
    }
    if (n >= b && m >= a) {
      for (size_t i = 0; i < n - b + 1; ++i) {
        for (size_t j = 0; j < m - a + 1; ++j) {
          size_t localmin = 0;
          for (size_t ii = i; ii < i + b; ++ii) {
            for (size_t jj = j; jj < j + a; ++jj) {
              if (garden[ii][jj] == 1) ++localmin;
            }
          }
          if (localmin < min) min = localmin;
        }
      }
    }
    cout << min;
    return 0;
  }
}
