#include <bits/stdc++.h>
using namespace std;
int fx[] = {0, 0, 1, -1, -1, 1, -1, 1};
int fy[] = {1, -1, 0, 0, -1, 1, 1, -1};
int arr[55][55];
int main() {
  int n, m, a, b;
  scanf("%d%*c", &n), scanf("%d%*c", &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d%*c", &arr[i][j]);
    }
  }
  scanf("%d%*c", &a), scanf("%d%*c", &b);
  int ans = 1000000000;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int co = 0;
      if ((i + a - 1) <= n && (j + b - 1) <= m) {
        for (int k = i; k <= (i + a - 1); k++) {
          for (int l = j; l <= (j + b - 1); l++) {
            if (arr[k][l] == 1) co++;
          }
        }
        if (co < ans) ans = co;
      }
      co = 0;
      if ((i + b - 1) <= n && (j + a - 1) <= m) {
        for (int k = i; k <= (i + b - 1); k++) {
          for (int l = j; l <= (j + a - 1); l++) {
            if (arr[k][l] == 1) co++;
          }
        }
        if (co < ans) ans = co;
      }
    }
  }
  printf("%d\n", ans);
}
