#include <bits/stdc++.h>
using namespace std;
int comulative_sum(int x, int y, int a, int b, int** land) {
  int sum = 0;
  for (int i = x; i < x + b; i++)
    for (int j = y; j < y + a; j++) sum += land[i][j];
  return sum;
}
int main(int argc, char** argv) {
  int x, y, a, b;
  cin >> x >> y;
  int** land = new int*[x];
  for (int i = 0; i < x; i++) {
    land[i] = new int[y];
    for (int j = 0; j < y; j++) cin >> land[i][j];
  }
  cin >> a >> b;
  int min_cut1 = x * y;
  int min_cut2 = x * y;
  for (int i = 0; i <= x - b; i++) {
    for (int j = 0; j <= y - a; j++) {
      min_cut1 = min(min_cut1, comulative_sum(i, j, a, b, land));
    }
  }
  for (int i = 0; i <= x - a; i++) {
    for (int j = 0; j <= y - b; j++) {
      min_cut2 = min(min_cut2, comulative_sum(i, j, b, a, land));
    }
  }
  cout << min(min_cut1, min_cut2) << endl;
  return 0;
}
