#include <bits/stdc++.h>
using namespace std;
void trace_() { cerr << "\n"; }
template <typename T1, typename... T2>
void trace_(T1 t1, T2... t2) {
  cerr << ' ' << t1;
  trace_(t2...);
}
string s;
long long n, m, x, y, p[1005], sum[1005];
long long dp[1005][2];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n >> m >> x >> y;
  for (long long i = 0; i < n; i++) {
    cin >> s;
    for (long long j = 0; j < m; j++) {
      if (s[j] == '#') p[j + 1]++;
    }
  }
  for (long long i = 1; i <= m; i++) {
    sum[i] = sum[i - 1] + p[i];
  }
  memset(dp, 0x3f, sizeof dp);
  dp[0][1] = dp[0][0] = 0;
  for (long long i = x; i <= m; i++) {
    for (long long j = i - y + 1; j <= i - x + 1; j++) {
      if (j < 1) continue;
      long long b = n * (i - j + 1) - (sum[i] - sum[j - 1]);
      long long w = n * (i - j + 1) - b;
      dp[i][1] = min(dp[i][1], dp[j - 1][0] + b);
      dp[i][0] = min(dp[i][0], dp[j - 1][1] + w);
    }
  }
  cout << min(dp[m][1], dp[m][0]) << '\n';
}
