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