#include <bits/stdc++.h>
using namespace std;
const int K = 410;
const int N = 1010;
const int M = 1000000007;
int n, m, x, y, dp[2][N], c[2][N];
char a[N][N];
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m >> x >> y;
  for (int i = 1; i <= n; ++i) cin >> (a[i] + 1);
  for (int j = 1; j <= m; ++j)
    for (int i = 1; i <= n; ++i) {
      c[0][j] += int(a[i][j] != '#');
      c[1][j] += int(a[i][j] != '.');
    }
  for (int cl = 0; cl < 2; ++cl)
    for (int i = 1; i <= m; ++i) c[cl][i] += c[cl][i - 1];
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0] = dp[1][0] = 0;
  for (int i = 1; i <= m; ++i)
    if (i - x >= 0)
      for (int j = max(i - y, 0); j <= i - x; ++j) {
        dp[0][i] = min(dp[0][i], dp[1][j] + c[0][i] - c[0][j]);
        dp[1][i] = min(dp[1][i], dp[0][j] + c[1][i] - c[1][j]);
      }
  int ans = min(dp[0][m], dp[1][m]);
  cout << ans << '\n';
}
