#include <bits/stdc++.h>
using namespace std;
int chopTree(const vector<vector<int> > &F, int I, int J, int A, int B) {
  int count = 0;
  for (int i = I; i < I + A; i++)
    for (int j = J; j < J + B; j++) {
      if (i < 0 || F.size() <= i || j < 0 || F[0].size() <= j) return -1;
      if (F[i][j] == 1) count++;
    }
  return count;
}
int main() {
  istream &is = cin;
  ostream &os = cout;
  int N, M;
  cin >> N >> M;
  vector<vector<int> > field(N, vector<int>(M));
  for (int n = 0; n < N; n++)
    for (int m = 0; m < M; m++) cin >> field[n][m];
  int a, b;
  cin >> a >> b;
  int mincount = 999999;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) {
      int count = chopTree(field, i, j, a, b);
      if (count != -1 && count < mincount) mincount = count;
      count = chopTree(field, i, j, b, a);
      if (count != -1 && count < mincount) mincount = count;
    }
  cout << mincount << endl;
  return 0;
}
