#include <bits/stdc++.h>
using namespace std;
int main() {
  bool x[50][50];
  int n, m, a, b, i, j, mi = 10000, now, f, g;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> x[i][j];
    }
  }
  cin >> a >> b;
  for (f = 0; f <= n - a; f++) {
    for (g = 0; g <= m - b; g++) {
      now = 0;
      for (i = 0; i < a; i++) {
        for (j = 0; j < b; j++) {
          now += x[f + i][g + j];
        }
      }
      mi = min(mi, now);
    }
  }
  for (f = 0; f <= n - b; f++) {
    for (g = 0; g <= m - a; g++) {
      now = 0;
      for (i = 0; i < b; i++) {
        for (j = 0; j < a; j++) {
          now += x[f + i][g + j];
        }
      }
      mi = min(mi, now);
    }
  }
  cout << mi << endl;
}
