#include <bits/stdc++.h>
using namespace std;
int dp[1001][2], n, a[1001], b[1001], m;
int solve(int pos, int x, int y, int c) {
  if (pos > m) return 999999;
  if (pos == m) return 0;
  if (dp[pos][c] != -1) return dp[pos][c];
  dp[pos][c] = 0;
  int i;
  for (i = 0; i < x; ++i) {
    if (i + pos >= m) {
      dp[pos][c] += 999999;
    } else {
      if (c)
        dp[pos][c] += a[i + pos];
      else
        dp[pos][c] += b[i + pos];
    }
  }
  int sum = 0;
  int mn = 9999999;
  mn = min(mn, solve(pos + x, x, y, !c));
  for (i = x; i < y && i + pos < m; ++i) {
    if (c)
      sum += a[i + pos];
    else
      sum += b[i + pos];
    mn = min(mn, sum + solve(pos + i + 1, x, y, !c));
  }
  dp[pos][c] += mn;
  return dp[pos][c];
}
int main() {
  int i, j, x, y, sum;
  bool arr[1001][1001];
  char c;
  cin >> n >> m >> x >> y;
  for (i = 0; i < n; ++i) {
    for (j = 0; j < m; ++j) {
      cin >> c;
      if (c == '.')
        arr[i][j] = 0;
      else
        arr[i][j] = 1;
    }
  }
  for (i = 0; i < m; ++i) {
    sum = 0;
    for (j = 0; j < n; ++j) {
      sum += arr[j][i];
    }
    a[i] = sum;
    b[i] = n - sum;
  }
  memset(dp, -1, sizeof(dp));
  solve(0, x, y, 0);
  cout << min(solve(0, x, y, 0), solve(0, x, y, 1));
  return 0;
}
