#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, v[51][51];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      cin >> v[i][j];
      v[i][j] += v[i - 1][j] + v[i][j - 1] - v[i - 1][j - 1];
    }
  cin >> a >> b;
  int res = n * m;
  for (int it = 0; it < 2; ++it) {
    if (a <= n && b <= m) {
      for (int r = 1; r <= n - a + 1; ++r)
        for (int c = 1; c <= m - b + 1; ++c)
          res = min(res, v[r + a - 1][c + b - 1] - v[r - 1][c + b - 1] -
                             v[r + a - 1][c - 1] + v[r - 1][c - 1]);
    }
    swap(a, b);
  }
  cout << res;
  return 0;
}
