#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, black[1005], white[1005];
int memo[1005][5];
string bar[1005];
int solve(int col, int gi) {
  if (col == m) return 0;
  if (memo[col][gi] != -1) return memo[col][gi];
  int cur, res = 1e7;
  for (int i = x; i <= y; i++) {
    if (col + i <= m)
      res =
          min(res, solve(col + i, 1 - gi) + (gi ? black[col + i] - black[col]
                                                : white[col + i] - white[col]));
  }
  return memo[col][gi] = res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> x >> y;
  for (int i = 0; i < n; i++) {
    cin >> bar[i];
  }
  black[0] = white[0] = 0;
  for (int j = 0; j < m; j++) {
    black[j + 1] = black[j];
    white[j + 1] = white[j];
    for (int i = 0; i < n; i++) {
      if (bar[i][j] == '#')
        black[j + 1]++;
      else
        white[j + 1]++;
    }
  }
  memset(memo, -1, sizeof(memo));
  int ans = min(solve(0, 0), solve(0, 1));
  cout << ans << '\n';
  return 0;
}
