#include <bits/stdc++.h>
const int N = 50, M = 50;
int field[N][M];
int n, m, a, b;
void ReadData() {
  scanf("%d%d", &n, &m);
  for (int row = 0; row < n; ++row)
    for (int col = 0; col < m; ++col) scanf("%d", &field[row][col]);
  scanf("%d%d", &a, &b);
}
int GetColSum(int col, int from, int to) {
  int sum = 0;
  for (int row = from; row < to; ++row) sum += field[row][col];
  return sum;
}
int GetAnswer(int a, int b) {
  int result = std::numeric_limits<int>::max();
  if (a > n || b > m) return result;
  for (int row = 0; row + a <= n; ++row) {
    int cur = 0;
    for (int col = 0; col < b; ++col) cur += GetColSum(col, row, row + a);
    result = std::min(result, cur);
    for (int col = b; col < m; ++col) {
      cur =
          cur + GetColSum(col, row, row + a) - GetColSum(col - b, row, row + a);
      result = std::min(result, cur);
    }
  }
  return result;
}
int main() {
  ReadData();
  int result = std::min(GetAnswer(a, b), GetAnswer(b, a));
  printf("%d\n", result);
  return 0;
}
