#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 10;
int ps[maxn][maxn], arr[maxn][maxn];
int a, b, n, m;
void input() {
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> arr[i][j];
  cin >> a >> b;
}
int main() {
  input();
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      ps[i + 1][j + 1] = ps[i + 1][j] + ps[i][j + 1] - ps[i][j] + arr[i][j];
  int ans = a * b;
  for (int i = a; i < n + 1; i++)
    for (int j = b; j < m + 1; j++)
      ans =
          min(ans, ps[i][j] - (ps[i - a][j] + ps[i][j - b] - ps[i - a][j - b]));
  for (int i = b; i < n + 1; i++)
    for (int j = a; j < m + 1; j++)
      ans =
          min(ans, ps[i][j] - (ps[i][j - a] + ps[i - b][j] - ps[i - b][j - a]));
  cout << ans << endl;
}
