#include <bits/stdc++.h>
using namespace std;
int n, m, x, y;
int dp[1001][1001][3];
int dots[1001];
int solve(int i, int col, int prev) {
  if (i == m) {
    if (col < x || col > y) {
      return 1000000;
    }
    return 0;
  }
  int& ret = dp[i][col][prev];
  if (~ret) {
    return ret;
  }
  int c1 = INT_MAX, c2 = INT_MAX;
  if (prev == 1) {
    if (col < x) {
      c1 = solve(i + 1, col + 1, 1) + (n - dots[i]);
    } else {
      if (col < y) {
        c1 = solve(i + 1, col + 1, 1) + (n - dots[i]);
        c2 = solve(i + 1, 1, 0) + dots[i];
      } else {
        c2 = solve(i + 1, 1, 0) + dots[i];
      }
    }
  } else if (prev == 0) {
    if (col < x) {
      c2 = solve(i + 1, col + 1, 0) + dots[i];
    } else {
      if (col < y) {
        c1 = solve(i + 1, 1, 1) + (n - dots[i]);
        c2 = solve(i + 1, col + 1, 0) + dots[i];
      } else {
        c1 = solve(i + 1, 1, 1) + (n - dots[i]);
      }
    }
  } else {
    c2 = solve(i + 1, col + 1, 0) + dots[i];
    c1 = solve(i + 1, col + 1, 1) + (n - dots[i]);
  }
  return ret = min(c1, c2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  memset(dp, -1, sizeof(dp));
  cin >> n >> m >> x >> y;
  char c;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> c;
      dots[j] += (c == '.');
    }
  }
  cout << solve(0, 0, 2) << '\n';
  return 0;
}
