#include <bits/stdc++.h>
using namespace std;
const int MAX = 60;
const int INF = 0x3f3f3f3f;
int a[MAX][MAX], sum[MAX][MAX];
int ans, n, m;
void check(int x, int y) {
  for (int j = 1; j + y - 1 <= m; ++j) {
    int s = 0;
    for (int i = 1; i <= n; ++i) {
      s += sum[i][j + y - 1] - sum[i][j - 1];
      if (i >= x) {
        s -= sum[i - x][j + y - 1] - sum[i - x][j - 1];
        ans = min(ans, s);
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> a[i][j];
      sum[i][j] = sum[i][j - 1] + a[i][j];
    }
  }
  int x, y;
  cin >> x >> y;
  ans = INF;
  check(x, y);
  check(y, x);
  cout << ans << endl;
}
