#include <bits/stdc++.h>
using namespace std;
int n, m, t[60][60], s = INT_MAX, x, y;
void f(int x, int y) {
  for (int i = 1; i <= n - x + 1; i++)
    for (int j = 1; j <= m - y + 1; j++) {
      int mn = 0;
      for (int k = i; k < i + x; k++)
        for (int l = j; l < j + y; l++) mn += t[k][l];
      s = min(s, mn);
    }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> t[i][j];
  cin >> x >> y;
  f(x, y);
  f(y, x);
  cout << s << endl;
  return 0;
}
