#include <bits/stdc++.h>
using namespace std;
int a[110][110], b[100010];
long long mn = 1e9, mx = -1e9, ans, cnt, sm;
bool ok, okk, used[1000010], use[10010];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  int x, y;
  cin >> x >> y;
  for (int i = 0; i <= n - x; i++) {
    for (int j = 0; j <= m - y; j++) {
      cnt = 0;
      for (int ii = i; ii < i + x; ii++) {
        for (int jj = j; jj < j + y; jj++) {
          if (a[ii][jj] == 1) {
            cnt++;
          }
        }
      }
      mn = min(cnt, mn);
    }
  }
  swap(x, y);
  for (int i = 0; i <= n - x; i++) {
    for (int j = 0; j <= m - y; j++) {
      cnt = 0;
      for (int ii = i; ii < i + x; ii++) {
        for (int jj = j; jj < j + y; jj++) {
          if (a[ii][jj] == 1) {
            cnt++;
          }
        }
      }
      mn = min(cnt, mn);
    }
  }
  cout << mn;
  return 0;
}
