#include <bits/stdc++.h>
using namespace std;
int solve(const vector<vector<int> >& v, size_t di, size_t dj) {
  int ans = 1e9;
  for (size_t si = 0; si + di <= v.size(); ++si)
    for (size_t sj = 0; sj + dj <= v[0].size(); ++sj) {
      int curr = 0;
      for (size_t i = si; i < si + di; ++i)
        for (size_t j = sj; j < sj + dj; ++j) curr += v[i][j];
      ans = min(ans, curr);
    }
  return ans;
}
int main() {
  size_t n, m;
  cin >> n >> m;
  vector<vector<int> > v(n, vector<int>(m));
  for (size_t i = 0; i < n; ++i)
    for (size_t j = 0; j < m; ++j) cin >> v[i][j];
  size_t a, b;
  cin >> a >> b;
  cout << min(solve(v, a, b), solve(v, b, a));
  return 0;
}
