#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int n, m, a, b;
char c[1004][1004];
int dp[5][1004], cnt[5][1004];
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &a, &b);
  for (int i = 1; i <= n; i++) scanf("%s", c[i] + 1);
  for (int j = 1; j <= m; j++)
    for (int i = 1; i <= n; i++)
      if (c[i][j] == '#')
        cnt[2][j]++;
      else
        cnt[1][j]++;
  for (int i = 1; i <= m; i++) {
    cnt[1][i] += cnt[1][i - 1];
    cnt[2][i] += cnt[2][i - 1];
  }
  for (int i = 1; i <= m; i++) dp[1][i] = dp[2][i] = INF;
  for (int i = 0; i < m; i++)
    for (int j = a; j <= b; j++) {
      int k = i + j;
      dp[1][k] = min(dp[1][k], dp[2][i] + cnt[1][k] - cnt[1][i]);
      dp[2][k] = min(dp[2][k], dp[1][i] + cnt[2][k] - cnt[2][i]);
    }
  printf("%d", min(dp[1][m], dp[2][m]));
  return 0;
}
