#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, n, a, b, m, e = 0, s = 0, sum = 0, st = 0, min = 0, end = 0,
                               j;
  cin >> n >> m;
  long long int arr[n][m];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) cin >> arr[i][j];
  }
  cin >> a >> b;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (arr[i][j] == 1) min += 1;
    }
  }
  if (a <= n && b <= m) {
    s = 0;
    e = a;
    st = 0;
    end = b;
    while (e <= n) {
      while (end <= m) {
        for (i = s; i < e; i++) {
          for (j = st; j < end; j++) {
            if (arr[i][j] == 1) sum += 1;
          }
        }
        if (min > sum) min = sum;
        sum = 0;
        st++;
        end++;
      }
      st = 0;
      end = b;
      s++;
      e++;
    }
  }
  if (a <= m && b <= n) {
    s = 0;
    e = b;
    st = 0;
    end = a;
    while (e <= n) {
      while (end <= m) {
        for (i = s; i < e; i++) {
          for (j = st; j < end; j++) {
            if (arr[i][j] == 1) sum += 1;
          }
        }
        if (min > sum) min = sum;
        sum = 0;
        st++;
        end++;
      }
      st = 0;
      end = a;
      s++;
      e++;
    }
  }
  cout << min << endl;
}
