#include <bits/stdc++.h>
using namespace std;
int n, m, a, b;
int g[60][60];
int count(int i1, int j1, int i2, int j2) {
  if (i2 >= n || j2 >= m) {
    return 1000000;
  }
  int cnt = 0;
  for (int i = i1; i <= i2; ++i) {
    for (int j = j1; j <= j2; ++j) {
      if (g[i][j] == 1) {
        ++cnt;
      }
    }
  }
  return cnt;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> g[i][j];
    }
  }
  cin >> a >> b;
  int ret = 1000000;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      ret = min(ret, count(i, j, i + a - 1, j + b - 1));
      ret = min(ret, count(i, j, i + b - 1, j + a - 1));
    }
  }
  cout << ret << endl;
  return 0;
}
