#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int tree[100][100];
  int treeb[100][100];
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> tree[i][j];
      treeb[j][i] = tree[i][j];
    }
  int a, b;
  int min = 9999999;
  cin >> a >> b;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int count = 999999;
      if (i + a <= n && j + b <= m) count = 0;
      for (int k = i; k < i + a && i + a <= n; k++) {
        for (int l = j; l < j + b && j + b <= m; l++) {
          if (tree[k][l] == 1) {
            count++;
          }
        }
      }
      if (count < min) min = count;
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      int count = 999999;
      if (i + a <= m && j + b <= n) count = 0;
      for (int k = i; k < i + a && i + a <= m; k++) {
        for (int l = j; l < j + b && j + b <= n; l++) {
          if (treeb[k][l] == 1) {
            count++;
          }
        }
      }
      if (count < min) min = count;
    }
  }
  cout << min << endl;
  return 0;
}
