#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
const int inf = 0x3f3f3f3f;
char a[maxn][maxn];
int dp[maxn][2], cnt[maxn], sum[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (a[i][j] == '#') cnt[j]++;
  for (int i = 0; i < m; i++) sum[i + 1] = sum[i] + cnt[i];
  memset(dp, 63, sizeof(dp));
  dp[0][0] = dp[0][1] = 0;
  for (int i = 0; i < m; i++) {
    for (int j = x; j <= y; j++) {
      if (i + j > m) break;
      dp[i + j][0] = min(dp[i + j][0], dp[i][1] + sum[i + j] - sum[i]);
      dp[i + j][1] =
          min(dp[i + j][1], dp[i][0] + n * j - (sum[i + j] - sum[i]));
    }
  }
  cout << min(dp[m][0], dp[m][1]) << endl;
  return 0;
}
