#include <bits/stdc++.h>
using namespace std;
int dp[1010][2];
char memo[1010][2];
int preto[1010];
int branco[1010];
int n, m, mn, mx;
char grid[1010][1010];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> mn >> mx;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> grid[i][j];
      if (grid[i][j] == '#')
        preto[j + 1]++;
      else
        branco[j + 1]++;
    }
  }
  memset(dp[0], 0, sizeof dp[0]);
  int custo;
  for (int pos = 1; pos <= m; pos++) {
    for (int cor = 0; cor < 2; cor++) {
      dp[pos][cor] = 1e9;
      custo = 0;
      for (int i = pos, cnt = 1; cnt <= mx && i >= 1; i--, cnt++) {
        if (cor == 0)
          custo += preto[i];
        else
          custo += branco[i];
        if (cnt >= mn && cnt <= mx) {
          dp[pos][cor] = min(dp[pos][cor], custo + dp[i - 1][cor ^ 1]);
        }
      }
    }
  }
  cout << min(dp[m][0], dp[m][1]) << "\n";
  return 0;
}
