#include <bits/stdc++.h>
using namespace std;
int a, b, num[100][100], heng[100][100], lie[100][100], i, j, n, m;
int qiu(int a, int b) {
  int s, x, l, r, y, ans, i, j, k;
  if (a > n || b > m) return (10000000);
  ans = 10000000;
  k = 0;
  for (i = 1; i <= a; i++) k = k + heng[i][b];
  for (i = 0; i <= m - b; i++) {
    l = 1 + i;
    r = b + i;
    ans = min(ans, k);
    y = k;
    for (j = 1; j <= n - a; j++) {
      s = j + 1;
      x = a + j;
      k = k - (heng[s - 1][r] - heng[s - 1][l - 1]) +
          (heng[x][r] - heng[x][l - 1]);
      ans = min(k, ans);
    }
    k = y - lie[l][a] + lie[r + 1][a];
  }
  return (ans);
}
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      scanf("%d", &num[i][j]);
      heng[i][j] = heng[i][j - 1] + num[i][j];
    }
  for (i = 1; i <= m; i++)
    for (j = 1; j <= n; j++) lie[i][j] = lie[i][j - 1] + num[j][i];
  scanf("%d%d", &a, &b);
  printf("%d\n", min(qiu(a, b), qiu(b, a)));
}
