#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 50 + 10, MAX_M = 50 + 10;
bool x[MAX_N][MAX_M];
int y[MAX_N][MAX_M], z[MAX_N][MAX_M];
int main() {
  int n, m, a, b;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> x[i][j];
    }
  }
  cin >> a >> b;
  for (int i = 0; i < n - a + 1; i++) {
    for (int j = 0; j < m - b + 1; j++) {
      for (int g = i; g <= i + a - 1; g++) {
        for (int h = j; h <= j + b - 1; h++) {
          y[i][j] += x[g][h];
        }
      }
    }
  }
  for (int i = 0; i < n - b + 1; i++) {
    for (int j = 0; j < m - a + 1; j++) {
      for (int g = i; g < i + b; g++) {
        for (int h = j; h < j + a; h++) {
          z[i][j] += x[g][h];
        }
      }
    }
  }
  int ans = 100000000;
  for (int i = 0; i < n - a + 1; i++) {
    for (int j = 0; j < m - b + 1; j++) {
      ans = min(ans, y[i][j]);
    }
  }
  for (int i = 0; i < n - b + 1; i++) {
    for (int j = 0; j < m - a + 1; j++) {
      ans = min(ans, z[i][j]);
    }
  }
  cout << ans;
}
