#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9;
const double PI = (double)acos(-1.0);
const double EPS = (double)1e-9;
const int MOD = (int)1e9 + 7;
int dat[55][55];
int main() {
  int n, m, x, y;
  scanf("%d %d", &n, &m);
  for (int i = 0; i <= n - 1; i += 1)
    for (int j = 0; j <= m - 1; j += 1) scanf("%d", &dat[i][j]);
  scanf("%d %d", &x, &y);
  int res = INF;
  for (int i = 0; i <= n - x + 1 - 1; i += 1)
    for (int j = 0; j <= m - y + 1 - 1; j += 1) {
      int ret = 0;
      for (int a = 0; a <= x - 1; a += 1)
        for (int b = 0; b <= y - 1; b += 1) ret += dat[i + a][j + b];
      res = min(res, ret);
    }
  for (int i = 0; i <= n - y + 1 - 1; i += 1)
    for (int j = 0; j <= m - x + 1 - 1; j += 1) {
      int ret = 0;
      for (int a = 0; a <= y - 1; a += 1)
        for (int b = 0; b <= x - 1; b += 1) ret += dat[i + a][j + b];
      res = min(res, ret);
    }
  printf("%d\n", res);
  return 0;
}
