#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 55;
const int inf = 1e9 + 77;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double eps = 1e-7;
int n, m, x, y;
int cs[2][1001];
int dp[1001][1001][2];
int solve(int id, int cnt, int lst) {
  if (id == m) {
    if (cnt >= x && cnt <= y) return 0;
    return inf;
  }
  int &res = dp[id][cnt][lst];
  if (res != -1) return res;
  res = inf;
  if (lst == 2) {
    res = min(solve(id + 1, 1, 0) + cs[0][0], solve(id + 1, 1, 1) + cs[1][0]);
  } else {
    if (cnt < x) {
      res = min(res, solve(id + 1, cnt + 1, lst) + cs[lst][id]);
    } else if (cnt < y) {
      res = min(res, solve(id + 1, cnt + 1, lst) + cs[lst][id]);
      res = min(res, solve(id + 1, 1, !lst) + cs[!lst][id]);
    } else
      res = min(res, solve(id + 1, 1, !lst) + cs[!lst][id]);
  }
  return res;
}
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &x);
  scanf("%d", &y);
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    for (int j = 0; j < m; ++j) {
      if (s[j] == '#') {
        cs[0][j]++;
      } else
        cs[1][j]++;
    }
  }
  memset(dp, -1, sizeof(dp));
  cout << solve(0, 0, 2);
  return 0;
}
