#include <bits/stdc++.h>
using namespace std;
int n, m, x, y;
int dp1[1005][2];
int dp[1005][1005][2];
int ans(int j, int k, int c) {
  if (j == m) {
    if (k < x || k > y)
      return 1e9 + 5;
    else
      return 0;
  }
  int &ret = dp[j][k][c];
  if (ret != -1) return ret;
  int mn = 1e9 + 5;
  if (k < x) {
    mn = min(mn, dp1[j][!c] + ans(j + 1, k + 1, c));
  }
  if (k >= x) {
    if (k < y) mn = min(mn, dp1[j][!c] + ans(j + 1, k + 1, c));
    mn = min(mn, dp1[j][c] + ans(j + 1, 1, !c));
  }
  return ret = mn;
}
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> n >> m >> x >> y;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++)
      if (s[j] == '.')
        dp1[j][1]++;
      else
        dp1[j][0]++;
  }
  if (m == 1) {
    cout << min(dp1[0][0], dp1[0][1]);
    return 0;
  }
  cout << min(ans(0, 0, 0), ans(0, 0, 1));
  return 0;
}
