#include <bits/stdc++.h>
using namespace std;
int n, m, a, b;
int mn = 1234567890;
int cnt(vector<vector<int> >& A, int i, int j) {
  int c = 0;
  for (int x = i; x < i + a; ++x)
    for (int y = j; y < j + b; ++y) {
      if (A[x][y] == 1) c++;
      if (c >= mn) return 1234567890;
    }
  return c;
}
int main() {
  cin >> n >> m;
  vector<vector<int> > A(n);
  for (int i = 0; i < int((A).size()); i++) A[i].resize(m);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) cin >> A[i][j];
  cin >> a >> b;
  int c;
  for (int i = 0; i < n - a + 1; ++i)
    for (int j = 0; j < m - b + 1; ++j) {
      c = cnt(A, i, j);
      if (c < mn) mn = c;
    }
  swap(a, b);
  for (int i = 0; i < n - a + 1; ++i)
    for (int j = 0; j < m - b + 1; ++j) {
      c = cnt(A, i, j);
      if (c < mn) mn = c;
    }
  cout << mn << endl;
  return 0;
}
