#include <bits/stdc++.h>
using namespace std;
void precompute() {}
const long long int N = 1005, INF = 1e16 + 5;
long long int dp[N][2];
void test_case() {
  long long int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<vector<long long int>> pref(m + 1, vector<long long int>(2)),
      cost(m + 1, vector<long long int>(2));
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= m; j++) {
      char ch;
      cin >> ch;
      if (ch == '.') {
        cost[j][0]++;
      } else {
        cost[j][1]++;
      }
    }
  }
  for (long long int i = 1; i <= m; i++) {
    for (long long int rep = 0; rep < 2; rep++) {
      cost[i][rep] += cost[i - 1][rep];
    }
  }
  for (long long int i = 0; i <= m; i++) {
    for (long long int rep = 0; rep < 2; rep++) {
      dp[i][rep] = INF;
    }
  }
  dp[0][0] = dp[0][1] = 0;
  for (long long int i = 1; i <= m; i++) {
    for (long long int j = x; j <= y; j++) {
      for (long long int rep = 0; rep < 2; rep++) {
        if (i - j >= 0) {
          dp[i][rep] = min(
              dp[i][rep], dp[i - j][rep ^ 1] + cost[i][rep] - cost[i - j][rep]);
        }
      }
    }
  }
  cout << min(dp[m][0], dp[m][1]) << '\n';
}
int32_t main() {
  srand(time(0));
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  precompute();
  long long int T = 1;
  for (long long int TT = 1; TT <= T; TT++) {
    test_case();
  }
  cerr << "Time : "
       << 1000 * ((long double)clock()) / (long double)CLOCKS_PER_SEC << "ms\n";
  return 0;
}
