#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, m, x, y, sup = 1;
vector<vector<int>> g;
int dp[1005][2], d[1005][2];
int INF = 1e7;
int main() {
  cin >> n >> m >> x >> y;
  g.resize(n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      char a;
      cin >> a;
      if (a == '#') g[i].push_back(1);
      if (a == '.') g[i].push_back(-1);
      dp[j][0] = INF;
      dp[j][1] = INF;
      d[j][0] = 0;
      d[j][1] = 0;
    }
  }
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      if (g[j][i] == -1) {
        d[i][1]++;
      } else {
        d[i][0]++;
      }
    }
    if (i > 0) {
      d[i][1] += d[i - 1][1];
      d[i][0] += d[i - 1][0];
    }
  }
  for (int i = 0; i < m; ++i) {
    for (int j = x; j <= y; ++j) {
      if (j > i + 1) {
        break;
      }
      if (j == i + 1) {
        dp[i][0] = min(dp[i][0], d[i][0]);
        dp[i][1] = min(dp[i][1], d[i][1]);
        break;
      }
      dp[i][0] = min(dp[i][0], dp[i - j][1] + d[i][0] - d[i - j][0]);
      dp[i][1] = min(dp[i][1], dp[i - j][0] + d[i][1] - d[i - j][1]);
    }
  }
  cout << min(dp[m - 1][0], dp[m - 1][1]);
}
