#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
int numb[MAXN], numw[MAXN];
int dp[MAXN][2];
string s[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (int i = 0; i < MAXN; i++) dp[i][0] = dp[i][1] = -1;
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int t = 0; t < m; t++) {
    int num = 0;
    for (int i = 0; i < n; i++)
      if (s[i][t] == '#') num++;
    numb[t] = num;
    numw[t] = n - num;
  }
  for (int t = 1; t < m; t++) numb[t] += numb[t - 1], numw[t] += numw[t - 1];
  for (int t = x - 1; t < m; t++) {
    for (int j = x; j <= y && t - j + 1 >= 0; j++) {
      if (t - j + 1 == 0) {
        if (dp[t][0] == -1) dp[t][0] = 1e9;
        if (dp[t][1] == -1) dp[t][1] = 1e9;
        dp[t][0] = min(dp[t][0], numb[t]);
        dp[t][1] = min(dp[t][1], numw[t]);
        continue;
      }
      if (dp[t - j][0] != -1) {
        if (dp[t][1] == -1) dp[t][1] = 1e9;
        dp[t][1] = min(dp[t][1], dp[t - j][0] + (numw[t] - numw[t - j]));
      }
      if (dp[t - j][1] != -1) {
        if (dp[t][0] == -1) dp[t][0] = 1e9;
        dp[t][0] = min(dp[t][0], dp[t - j][1] + (numb[t] - numb[t - j]));
      }
    }
  }
  cout << min(dp[m - 1][0], dp[m - 1][1]) << "\n";
}
