#include <bits/stdc++.h>
using namespace std;
template <typename S, typename T>
void fill_(S& buf, const T& x) {
  fill_n(reinterpret_cast<T*>(&buf), sizeof(buf) / sizeof(T), x);
}
template <typename T, int N>
inline int countof(const T (&)[N]) {
  return N;
}
template <typename T>
inline vector<T>& operator+=(vector<T>& ret, const T& x) {
  ret.push_back(x);
  return ret;
}
int N, M;
vector<vector<int>> board;
int solve(int h, int w) {
  int best = INT_MAX;
  for (int y = int(0), CNT_y = int(N); y < CNT_y; ++y)
    for (int x = int(0), CNT_x = int(M); x < CNT_x; ++x)
      if (y + h <= N && x + w <= M) {
        int acc = 0;
        for (int i = int(y), CNT_i = int(y + h); i < CNT_i; ++i)
          for (int j = int(x), CNT_j = int(x + w); j < CNT_j; ++j)
            acc += board[i][j];
        best = min(best, acc);
      }
  return best;
}
int main(int argc, char* argv[]) {
  cin >> N >> M;
  board.assign(N, vector<int>(M));
  for (int n = int(0), CNT_n = int(N); n < CNT_n; ++n)
    for (int m = int(0), CNT_m = int(M); m < CNT_m; ++m) cin >> board[n][m];
  int a, b;
  cin >> a >> b;
  cout << min(solve(a, b), solve(b, a)) << endl;
  return 0;
}
