#include <bits/stdc++.h>
using namespace std;
int a, b, n, m;
int dp[1024][1024][2], cant[1024][2];
int F(int i, int r, int l) {
  if (i == m - 1 && r + 1 >= a && r + 1 <= b) {
    return cant[i][l];
  }
  if (i == m) return 1e9;
  if (dp[i][r][l] != -1) return dp[i][r][l];
  int ans = 1e9;
  if (r + 1 < a) {
    ans = min(ans, cant[i][l] + F(i + 1, r + 1, l));
  } else {
    if (r + 1 >= b) {
      ans = min(ans, cant[i][l] + F(i + 1, 0, (l + 1) % 2));
    } else {
      ans = min(ans, cant[i][l] + F(i + 1, 0, (l + 1) % 2));
      ans = min(ans, cant[i][l] + F(i + 1, r + 1, l));
    }
  }
  return dp[i][r][l] = ans;
}
char cad[1024];
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%d %d %d %d", &n, &m, &a, &b);
  for (int i = 0; i < n; i++) {
    scanf("%s", cad);
    int len = strlen(cad);
    for (int j = 0; j < len; j++) {
      if (cad[j] == '#') {
        cant[j][0]++;
      } else {
        cant[j][1]++;
      }
    }
  }
  printf("%d\n", min(F(0, 0, 0), F(0, 0, 1)));
  return 0;
}
