#include <bits/stdc++.h>
int tree[70][70];
int max_x = 70 - 1, max_y = 70 - 1;
int lowbit(int n) { return n & (-n); }
void change(int x, int y, int delta) {
  int yt;
  while (x <= max_x) {
    yt = y;
    while (yt <= max_y) {
      tree[x][yt] += delta;
      yt += lowbit(yt);
    }
    x += lowbit(x);
  }
}
int getsum(int x, int y) {
  int ans = 0, yt;
  while (x > 0) {
    yt = y;
    while (yt > 0) {
      ans += tree[x][yt];
      yt -= lowbit(yt);
    }
    x -= lowbit(x);
  }
  return ans;
}
int main() {
  int n, m;
  int input;
  int a, b, ans, cand;
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(tree, 0, sizeof(tree));
    max_x = n + 2, max_y = m + 2;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        scanf("%d", &input);
        if (input == 1) change(i, j, 1);
      }
    }
    ans = n * m + 1;
    scanf("%d%d", &a, &b);
    a--, b--;
    for (int i = 1; i <= n - a; i++) {
      for (int j = 1; j <= m - b; j++) {
        cand = getsum(i + a, j + b) - getsum(i - 1, j + b) -
               getsum(i + a, j - 1) + getsum(i - 1, j - 1);
        if (ans > cand) ans = cand;
      }
    }
    for (int i = 1; i <= n - b; i++) {
      for (int j = 1; j <= m - a; j++) {
        cand = getsum(i + b, j + a) - getsum(i - 1, j + a) -
               getsum(i + b, j - 1) + getsum(i - 1, j - 1);
        if (ans > cand) ans = cand;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
