#include <bits/stdc++.h>
using namespace std;
template <typename T>
void dbg(T t) {
  cerr << t << endl;
}
template <typename T, typename... Args>
void dbg(T t, Args... args) {
  cerr << t << " ";
  dbg(args...);
}
int n, m, x, y;
string t[1000];
int pre[1001];
int dp[1001][2];
int solv(int col, int WHITE) {
  if (col >= m) {
    dbg("never,i");
    return 0;
  }
  if (dp[col][WHITE] != 1061109567) return dp[col][WHITE];
  if (WHITE) {
    for (int i = x; i <= y; i++) {
      if (col + i == m) {
        return dp[col][WHITE] = min(dp[col][WHITE], pre[col + i] - pre[col]);
      } else if (col + i < m)
        dp[col][WHITE] = min(dp[col][WHITE], pre[col + i] - pre[col] +
                                                 solv(col + i, (WHITE ^ 1)));
    }
  } else {
    for (int i = x; i <= y; i++) {
      if (col + i == m) {
        return dp[col][WHITE] =
                   min(dp[col][WHITE], n * i - pre[col + i] + pre[col]);
      } else if (col + i < m) {
        dp[col][WHITE] = min(dp[col][WHITE], n * i - pre[col + i] + pre[col] +
                                                 solv(col + i, (WHITE ^ 1)));
      }
    }
  }
  return dp[col][WHITE];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> x >> y;
  for (int i = 0; i < n; i++) cin >> t[i];
  pre[0] = 0;
  memset(dp, 63, sizeof(dp));
  for (int j = 0; j < m; j++) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (t[i][j] == '#') cnt++;
      pre[j + 1] = cnt;
    }
  }
  for (int i = 0; i < m; i++) pre[i + 1] += pre[i];
  cout << min(solv(0, 1), solv(0, 0)) << endl;
  return 0;
}
