#include <bits/stdc++.h>
int main() {
  int n, m, a, b, i, j, min, temp, map[55][55], save[55][55];
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(save, 0, sizeof(save));
    memset(map, 0, sizeof(map));
    for (i = 1; i <= n; i++)
      for (j = 1; j <= m; j++) {
        scanf("%d", &map[i][j]);
        save[i][j] =
            map[i][j] + save[i - 1][j] + save[i][j - 1] - save[i - 1][j - 1];
      }
    scanf("%d%d", &a, &b);
    min = 100000;
    for (i = 1; i <= n; i++)
      for (j = 1; j <= m; j++) {
        if (i <= n - a + 1 && j <= m - b + 1) {
          temp = save[i + a - 1][j + b - 1] - save[i - 1][j + b - 1] -
                 save[i + a - 1][j - 1] + save[i - 1][j - 1];
          if (temp < min) min = temp;
        }
        if (i <= n - b + 1 && j <= m - a + 1) {
          temp = save[i + b - 1][j + a - 1] - save[i - 1][j + a - 1] -
                 save[i + b - 1][j - 1] + save[i - 1][j - 1];
          if (temp < min) min = temp;
        }
      }
    printf("%d\n", min);
  }
  return 0;
}
