#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int m, n, res, a, b, mas[50][50], i, j, k, l, min = 100000, s = 0;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> mas[i][j];
    }
  }
  cin >> a >> b;
  for (i = 0; i <= n - a; i++) {
    for (j = 0; j <= m - b; j++) {
      s = 0;
      for (k = i; k < i + a; k++) {
        for (l = j; l < j + b; l++) {
          if (mas[k][l] == 1) {
            s++;
          }
        }
      }
      if (s < min) min = s;
    }
  }
  k = a;
  a = b;
  b = k;
  for (i = 0; i <= n - a; i++) {
    for (j = 0; j <= m - b; j++) {
      s = 0;
      for (k = i; k < i + a; k++) {
        for (l = j; l < j + b; l++) {
          if (mas[k][l] == 1) {
            s++;
          }
        }
      }
      if (s < min) min = s;
    }
  }
  cout << min;
  return EXIT_SUCCESS;
}
