#include <bits/stdc++.h>
using namespace std;
int dp[1010][2];
char memo[1010][2];
int preto[1010];
int branco[1010];
int n, m, mn, mx;
char grid[1010][1010];
int solve(int pos, int cor) {
  if (pos >= m) return 0;
  if (memo[pos][cor]) return dp[pos][cor];
  memo[pos][cor] = 1;
  int ans = 1e9, custo = 0;
  for (int i = pos, cnt = 1; cnt <= mx && i < m; i++, cnt++) {
    if (cor == 0)
      custo += preto[i];
    else
      custo += branco[i];
    if (cnt >= mn && cnt <= mx) {
      ans = min(ans, custo + solve(i + 1, cor ^ 1));
    }
  }
  return dp[pos][cor] = ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> mn >> mx;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> grid[i][j];
      if (grid[i][j] == '#')
        preto[j]++;
      else
        branco[j]++;
    }
  }
  cout << min(solve(0, 0), solve(0, 1)) << "\n";
  return 0;
}
