#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, a, b;
  cin >> n >> m;
  int land[n + 1][m + 1];
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++) {
      if (i == 0 || j == 0)
        land[i][j] = 0;
      else
        cin >> land[i][j];
    }
  cin >> a >> b;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      land[i][j] += land[i - 1][j] + land[i][j - 1] - land[i - 1][j - 1];
  int mn = 10000;
  for (int i = a; i <= n; i++)
    for (int j = b; j <= m; j++)
      mn = min(mn, land[i][j] - land[i - a][j] - land[i][j - b] +
                       land[i - a][j - b]);
  for (int i = b; i <= n; i++)
    for (int j = a; j <= m; j++)
      mn = min(mn, land[i][j] - land[i - b][j] - land[i][j - a] +
                       land[i - b][j - a]);
  cout << mn;
  return 0;
}
