#include <bits/stdc++.h>
using namespace std;
int n, m;
int sj[1001];
string s[1001];
bool vis[1001][2];
int dp[1001][2];
int x, y;
int solve(int i, int j) {
  if (i == m) return 0;
  if (vis[i][j]) return dp[i][j];
  vis[i][j] = 1;
  int cc = 0;
  dp[i][j] = 100000000;
  for (int w = i; w < m; w++) {
    cc += sj[w];
    int k = w - i + 1;
    int custo = cc;
    if (j) custo = k * n - cc;
    if (k >= x && k <= y) {
      dp[i][j] = min(dp[i][j], solve(w + 1, !j) + custo);
    }
  }
  return dp[i][j];
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> x >> y;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (s[j][i] == '.') sj[i]++;
    }
  }
  cout << min(solve(0, 1), solve(0, 0));
}
