#include <bits/stdc++.h>
using namespace std;
int n, m;
int x, y;
int ans = 10000000;
int bar[2001];
int dp[1002][1002][2];
string str[2001];
int dfs(int si) {
  int res = 10000000;
  for (int i = 0; i < m - si; i++) {
    int rr = 0;
    for (int j = 0; j < m; j++) {
      if (j >= i && j < i + si)
        rr += n - bar[j];
      else
        rr += bar[j];
    }
    res = min(rr, res);
  }
  return res;
}
int main(void) {
  for (int i = 0; i <= 1001; i++) {
    for (int j = 0; j <= 1001; j++) {
      dp[i][j][0] = dp[i][j][1] = 10000000;
    }
  }
  scanf("%d%d%d%d", &n, &m, &x, &y);
  for (int i = 0; i < n; i++) {
    cin >> str[i];
    for (int j = 0; j < m; j++) {
      if (str[i][j] == '#') bar[j]++;
    }
  }
  dp[0][0][0] = 0;
  dp[0][0][1] = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 1; j <= y; j++) {
      if (j >= x) dp[i + 1][1][0] = min(dp[i + 1][1][0], dp[i][j][1] + bar[i]);
      if (j >= x)
        dp[i + 1][1][1] = min(dp[i + 1][1][1], dp[i][j][0] + n - bar[i]);
      dp[i + 1][j][0] = min(dp[i + 1][j][0], dp[i][j - 1][0] + bar[i]);
      dp[i + 1][j][1] = min(dp[i + 1][j][1], dp[i][j - 1][1] + n - bar[i]);
    }
  }
  for (int i = x; i <= y; i++) ans = min(ans, min(dp[m][i][1], dp[m][i][0]));
  printf("%d\n", ans);
  return 0;
}
