#include <bits/stdc++.h>
using namespace std;
const int maxn = 50 + 10, INF = 1e9;
int mtrx[maxn][maxn];
int main() {
  int n, m, a, b;
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> mtrx[i][j];
  cin >> a >> b;
  int result = INF;
  int cnt;
  for (int x = 0; x < 2; x++) {
    for (int i = 0; i <= n - a; i++)
      for (int j = 0; j <= m - b; j++) {
        cnt = 0;
        for (int l = 0; l < a; l++)
          for (int k = 0; k < b; k++) cnt += mtrx[i + l][j + k];
        result = min(result, cnt);
      }
    swap(a, b);
  }
  cout << result << endl;
  return 0;
}
