#include <bits/stdc++.h>
using namespace std;
int a[101][101];
int main() {
  int i, j, k, kk, l, m, n;
  while (~scanf("%d %d", &n, &m)) {
    memset(a, -1, sizeof(a));
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        scanf("%d", &a[i][j]);
      }
    }
    int x, y;
    int mi = 100000000;
    scanf("%d %d", &x, &y);
    int cnt;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        cnt = 0;
        for (k = i; k < i + x; k++) {
          for (kk = j; kk < j + y; kk++) {
            if (a[k][kk] != 0) cnt++;
          }
        }
        if (cnt < mi) mi = cnt;
        cnt = 0;
        for (k = i; k < i + y; k++) {
          for (kk = j; kk < j + x; kk++) {
            if (a[k][kk] != 0) cnt++;
          }
        }
        if (cnt < mi) mi = cnt;
      }
    }
    printf("%d\n", mi);
  }
  return 0;
}
