#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int A[55][55] = {};
  int fr[55][55] = {};
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> A[i][j];
      fr[i][j] = A[i][j] + fr[i][j - 1] + fr[i - 1][j] - fr[i - 1][j - 1];
    }
  }
  int a, b;
  cin >> a >> b;
  int mn = 100000;
  for (int i = a; i <= n; i++) {
    for (int j = b; j <= m; j++) {
      int sum;
      sum = fr[i][j] - fr[i - a][j] - fr[i][j - b] + fr[i - a][j - b];
      mn = min(mn, sum);
    }
  }
  int t = a;
  a = b;
  b = t;
  for (int i = a; i <= n; i++) {
    for (int j = b; j <= m; j++) {
      int sum;
      sum = fr[i][j] - fr[i - a][j] - fr[i][j - b] + fr[i - a][j - b];
      mn = min(mn, sum);
    }
  }
  cout << mn;
  return 0;
}
