#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b;
  int res = 10000;
  scanf("%d %d", &n, &m);
  vector<vector<int> > v(n);
  for (int i = 0; i < n; i++) {
    v[i].assign(m, 0);
    for (int j = 0; j < m; j++) {
      scanf("%d", &v[i][j]);
    }
  }
  scanf("%d %d", &a, &b);
  for (int i = 0; i < n - a + 1; i++) {
    for (int j = 0; j < m - b + 1; j++) {
      int c = 0;
      for (int k = 0; k < a; k++) {
        for (int l = 0; l < b; l++) {
          if (v[i + k][j + l] == 1) c++;
        }
      }
      if (c < res) res = c;
    }
  }
  for (int i = 0; i < n - b + 1; i++) {
    for (int j = 0; j < m - a + 1; j++) {
      int c = 0;
      for (int k = 0; k < b; k++) {
        for (int l = 0; l < a; l++) {
          if (v[i + k][j + l] == 1) c++;
        }
      }
      if (c < res) res = c;
    }
  }
  printf("%d\n", res);
  return 0;
}
