#include <bits/stdc++.h>
using namespace std;
int n, m, x, y;
char a[1024][1024];
int dp[1024][2];
int b[1024], w[1024], sum[1024][2];
int main() {
  cin >> n >> m >> x >> y;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = 0; j < m; j++)
      if (a[i][j] == '#')
        b[j]++;
      else
        w[j]++;
  }
  sum[0][0] = b[0];
  sum[0][1] = w[0];
  for (int i = 0; i < m - 1; i++) {
    sum[i + 1][0] = sum[i][0] + b[i + 1];
    sum[i + 1][1] = sum[i][1] + w[i + 1];
  }
  for (int i = 0; i < m; i++)
    for (int j = 0; j < 2; j++) dp[i][j] = -1;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < 2; j++) {
      int min_cost = 1e9;
      for (int k = x; k <= y; k++) {
        if (i < k - 1) continue;
        if (i == k - 1)
          min_cost = min(min_cost, sum[i][1 - j]);
        else {
          if (dp[i - k][1 - j] == -1)
            continue;
          else
            min_cost = min(
                min_cost, dp[i - k][1 - j] + sum[i][1 - j] - sum[i - k][1 - j]);
        }
      }
      if (min_cost == 1e9)
        dp[i][j] = -1;
      else
        dp[i][j] = min_cost;
    }
  cout << min(dp[m - 1][0], dp[m - 1][1]) << endl;
  return 0;
}
