#include <bits/stdc++.h>
using namespace std;
int n, m, a, b;
int grid[55][55];
inline int check(int r, int c, int a, int b) {
  if (r + a > n) return 2147483647;
  if (c + b > m) return 2147483647;
  int res = 0;
  for (int i = r; i < r + a; i++)
    for (int j = c; j < c + b; j++) res += grid[i][j];
  return res;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> grid[i][j];
  cin >> a >> b;
  int res = 2147483647;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      int sc = check(i, j, a, b);
      res = min(res, sc);
      res = min(res, check(i, j, b, a));
    }
  cout << res << endl;
  return 0;
}
