#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int dp[2][maxn], w[maxn], b[maxn];
int main() {
  int m, n, c, d;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> m >> n >> c >> d;
  for (int i = (1); i <= (int)(m); ++i)
    for (int j = (1); j <= (int)(n); ++j) {
      char ch;
      cin >> ch;
      if (ch == '.')
        ++w[j];
      else
        ++b[j];
      if (i == m && j > 0) {
        w[j] += w[j - 1];
        b[j] += b[j - 1];
      }
    }
  for (int i = (1); i <= (int)(n); ++i) dp[0][i] = dp[1][i] = INT_MAX / 2;
  for (int i = (1); i <= (int)(n); ++i)
    for (int j = (c); j <= (int)(d); ++j) {
      if (i - j < 0) continue;
      dp[0][i] = min(dp[0][i], dp[1][i - j] - w[i - j] + w[i]);
      dp[1][i] = min(dp[1][i], dp[0][i - j] - b[i - j] + b[i]);
    }
  cout << min(dp[0][n], dp[1][n]);
}
