#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int arr[51][51];
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> arr[i][j];
  int a, b;
  cin >> a >> b;
  int best = a * b, c = 0;
  for (int i = 0; i <= n - a; i++)
    for (int j = 0; j <= m - b; j++) {
      c = 0;
      for (int p = 0; p < a; p++)
        for (int q = 0; q < b; q++) c += arr[i + p][j + q];
      best = min(best, c);
    }
  swap(a, b);
  for (int i = 0; i <= n - a; i++)
    for (int j = 0; j <= m - b; j++) {
      c = 0;
      for (int p = 0; p < a; p++)
        for (int q = 0; q < b; q++) c += arr[i + p][j + q];
      best = min(best, c);
    }
  cout << best << endl;
  return 0;
}
