#include <bits/stdc++.h>
using namespace std;
const int MAXN = 50;
int m, n, a, b;
int gar[MAXN][MAXN];
int main() {
  cin >> m >> n;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      cin >> gar[i][j];
    }
  }
  cin >> a >> b;
  int minOne = 2501;
  for (int r = 0; r < 2; r++) {
    for (int i = 0; i <= m - a; i++) {
      for (int j = 0; j <= n - b; j++) {
        int t = 0;
        for (int k = i; k < i + a; k++) {
          for (int l = j; l < j + b; l++) {
            t += gar[k][l];
          }
        }
        if (minOne > t) {
          minOne = t;
        }
      }
    }
    swap(a, b);
  }
  cout << minOne << endl;
  return 0;
}
