#include <bits/stdc++.h>
using namespace std;
const int MAXN = 55;
int N, M, A, B;
int dp[MAXN][MAXN];
int solve(int a, int b) {
  int ans = 1 << 30;
  for (int i = 1; i + a - 1 <= N; i++) {
    for (int j = 1; j + b - 1 <= M; j++) {
      ans = min(ans, dp[i + a - 1][j + b - 1] - dp[i + a - 1][j - 1] -
                         dp[i - 1][j + b - 1] + dp[i - 1][j - 1]);
    }
  }
  return ans;
}
int main(int argc, char *argv[]) {
  scanf("%d%d", &N, &M);
  for (int i = 0, _i = N; i < _i; ++i) {
    for (int j = 0, _j = M; j < _j; ++j) {
      int x;
      scanf("%d", &x);
      dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j] - dp[i][j] + x;
    }
  }
  scanf("%d%d", &A, &B);
  cout << min(solve(A, B), solve(B, A));
  return 0;
}
