#include <bits/stdc++.h>
using namespace std;
int sum[(100)][(100)];
int m, n, x, y, ans;
int main() {
  ans = 1000000;
  scanf("%d%d", &m, &n);
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) {
      scanf("%d", &sum[i][j]);
      sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
    }
  scanf("%d%d", &x, &y);
  for (int i = x; i <= m; i++)
    for (int j = y; j <= n; j++)
      ans = min(ans,
                sum[i][j] - sum[i - x][j] - sum[i][j - y] + sum[i - x][j - y]);
  swap(x, y);
  for (int i = x; i <= m; i++)
    for (int j = y; j <= n; j++)
      ans = min(ans,
                sum[i][j] - sum[i - x][j] - sum[i][j - y] + sum[i - x][j - y]);
  printf("%d\n", ans);
  return 0;
}
