#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, m;
  cin >> n >> m;
  int field[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> field[i][j];
    }
  }
  long a, b, cnt = 0, mini = 1e9;
  cin >> a >> b;
  for (int i = 0; i <= n - a; i++) {
    for (int j = 0; j <= m - b; j++) {
      cnt = 0;
      for (int k = i; k < i + a; k++) {
        for (int l = j; l < j + b; l++) {
          if (field[k][l] == 1) {
            cnt++;
          }
        }
      }
      mini = min(cnt, mini);
    }
    if (mini == 0) {
      break;
    }
  }
  if (mini) {
    for (int i = 0; i <= n - b; i++) {
      for (int j = 0; j <= m - a; j++) {
        cnt = 0;
        for (int k = i; k < i + b; k++) {
          for (int l = j; l < j + a; l++) {
            if (field[k][l] == 1) {
              cnt++;
            }
          }
        }
        mini = min(cnt, mini);
      }
      if (mini == 0) {
        break;
      }
    }
  }
  cout << mini << "\n";
  return 0;
}
