#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b;
  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];
    }
  }
  cin >> a >> b;
  bool same;
  if (a == b) {
    same = true;
  } else {
    same = false;
  }
  int minimum = 1000000000;
  for (int i = 0; i <= n - a; i++) {
    for (int j = 0; j <= m - b; j++) {
      bool over = false;
      int cut_trees = 0;
      for (int k = i; k < i + a; k++) {
        for (int l = j; l < j + b; l++) {
          if (field[k][l] == 1) {
            cut_trees++;
          }
          if (cut_trees >= minimum) {
            over = true;
            break;
          }
        }
        if (over) {
          break;
        }
      }
      if (cut_trees < minimum) {
        minimum = cut_trees;
      }
    }
  }
  if (!same) {
    for (int i = 0; i <= n - b; i++) {
      for (int j = 0; j <= m - a; j++) {
        bool over = false;
        int cut_trees = 0;
        for (int k = i; k < i + b; k++) {
          for (int l = j; l < j + a; l++) {
            if (field[k][l] == 1) {
              cut_trees++;
            }
            if (cut_trees >= minimum) {
              over = true;
              break;
            }
          }
          if (over) {
            break;
          }
        }
        if (cut_trees < minimum) {
          minimum = cut_trees;
        }
      }
    }
  }
  cout << minimum << endl;
  return 0;
}
