#include <bits/stdc++.h>
using namespace std;
int n, m, v[55][55], a, b, minTree = 55 * 55;
void CheckHouse(int a, int b) {
  for (int i = 1; i <= n - a + 1; i++) {
    for (int j = 1; j <= m - b + 1; j++) {
      int trees = 0;
      for (int ai = i; ai <= i + a - 1; ai++) {
        for (int aj = j; aj <= j + b - 1; aj++) {
          if (v[ai][aj] == 1) trees++;
        }
      }
      if (trees < minTree) {
        minTree = trees;
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> v[i][j];
    }
  }
  cin >> a >> b;
  CheckHouse(a, b);
  CheckHouse(b, a);
  cout << minTree;
  return 0;
}
