#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 3, inf = 1e9 + 7;
int n, m, x, y, ans = inf;
int Arr[MAXN];
int psum[MAXN];
int dp[MAXN][MAXN][2];
int cnt[MAXN][2];
bool table[MAXN][MAXN];
int main() {
  scanf("%d%d%d%d", &n, &m, &x, &y);
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (int j = 1; j <= m; j++) table[i][j] = (s[j - 1] == '#');
  }
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) Arr[i] += table[j][i];
  for (int i = 1; i <= m; i++) psum[i] = psum[i - 1] + Arr[i];
  for (int i = 1; i <= m; i++) {
    cnt[i][0] = cnt[i][1] = inf;
    for (int j = x; j <= min(y, i); j++) {
      dp[i][j][0] = psum[i] - psum[i - j] + cnt[i - j][1];
      dp[i][j][1] = (j * n) - psum[i] + psum[i - j] + cnt[i - j][0];
      cnt[i][0] = min(cnt[i][0], dp[i][j][0]);
      cnt[i][1] = min(cnt[i][1], dp[i][j][1]);
    }
  }
  for (int i = x; i <= min(y, m); i++)
    ans = min({ans, dp[m][i][0], dp[m][i][1]});
  printf("%d", ans);
}
