#include <bits/stdc++.h>
using namespace std;
int i, j;
int a[55][55], d[55][55];
int b[111];
int m, n, k, l, r, z, x, y, xx, yy, x1, y_1;
long long t, tp, ans;
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      cin >> a[i][j];
      d[i][j] = d[i - 1][j] + d[i][j - 1] - d[i - 1][j - 1] + a[i][j];
    }
  cin >> x >> y;
  ans = n * m;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      if (i - x + 1 > 0 && j - y + 1 > 0) {
        t = d[i][j] - d[i - x][j] - d[i][j - y] + d[i - x][j - y];
        ans = min(ans, t);
      }
      if (i - y + 1 > 0 && j - x + 1 > 0) {
        t = d[i][j] - d[i - y][j] - d[i][j - x] + d[i - y][j - x];
        ans = min(ans, t);
      }
    }
  cout << ans;
}
