#include <bits/stdc++.h>
long long mod = 1e9 + 7;
using namespace std;
char str[1005][1005];
int black[1005];
int white[1005];
int dp[1005][2];
int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  int i, j;
  for (i = 0; i < n; i++) scanf("%s", str[i]);
  for (i = 0; i < 1006; i++) {
    black[i] = 0;
    white[i] = 0;
    dp[i][0] = 1000000;
    dp[i][1] = 1000000;
  }
  for (i = 0; i < m; i++) {
    if (i != 0) {
      black[i] += black[i - 1];
      white[i] += white[i - 1];
    }
    for (j = 0; j < n; j++) {
      if (str[j][i] == '.')
        white[i]++;
      else
        black[i]++;
    }
  }
  for (i = m; i >= 1; i--) {
    white[i] = white[i - 1];
    black[i] = black[i - 1];
  }
  white[0] = 0;
  black[0] = 0;
  dp[0][1] = 0;
  dp[0][0] = 0;
  for (i = 0; i < m; i++) {
    for (j = x; j <= y; j++) {
      if (i + j <= m) {
        dp[i + j][0] = min(dp[i + j][0], dp[i][1] + white[i + j] - white[i]);
        dp[i + j][1] = min(dp[i + j][1], dp[i][0] + black[i + j] - black[i]);
      }
    }
  }
  cout << min(dp[m][0], dp[m][1]);
}
