#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, n, m, c, i, j, k, l;
  scanf("%d%d", &n, &m);
  int ara[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &ara[i][j]);
  scanf("%d%d", &a, &b);
  if ((a <= n && b <= m) && (a <= m && b <= n)) {
    vector<int> v1, v2;
    for (i = 0; i <= n - a; i++) {
      for (j = 0; j <= m - b; j++) {
        for (k = i, c = 0; k < a + i; k++) {
          for (l = j; l < b + j; l++) {
            if (ara[k][l] == 1) c++;
          }
        }
        v1.push_back(c);
      }
    }
    for (i = 0; i <= n - b; i++) {
      for (j = 0; j <= m - a; j++) {
        for (k = i, c = 0; k < b + i; k++) {
          for (l = j; l < a + j; l++) {
            if (ara[k][l] == 1) c++;
          }
        }
        v2.push_back(c);
      }
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    printf("%d\n", min(v1[0], v2[0]));
  } else if (a <= n && b <= m) {
    vector<int> v1;
    for (i = 0; i <= n - a; i++) {
      for (j = 0; j <= m - b; j++) {
        for (k = i, c = 0; k < a + i; k++) {
          for (l = j; l < b + j; l++) {
            if (ara[k][l] == 1) c++;
          }
        }
        v1.push_back(c);
      }
    }
    sort(v1.begin(), v1.end());
    printf("%d\n", v1[0]);
  } else {
    vector<int> v2;
    for (i = 0; i <= n - b; i++) {
      for (j = 0; j <= m - a; j++) {
        for (k = i, c = 0; k < b + i; k++) {
          for (l = j; l < a + j; l++) {
            if (ara[k][l] == 1) c++;
          }
        }
        v2.push_back(c);
      }
    }
    sort(v2.begin(), v2.end());
    printf("%d\n", v2[0]);
  }
  return 0;
}
